当前位置: 首页>>代码示例>>C#>>正文


C# Vector3D.GetDim方法代码示例

本文整理汇总了C#中Vector3D.GetDim方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3D.GetDim方法的具体用法?C# Vector3D.GetDim怎么用?C# Vector3D.GetDim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector3D的用法示例。


在下文中一共展示了Vector3D.GetDim方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TargetAction

    private void TargetAction(ZACommons commons, Vector3D target)
    {
        var targetGroup = commons.GetBlockGroupWithName(RANGEFINDER_TARGET_GROUP);
        if (targetGroup != null)
        {
            var targetString = string.Format(RANGEFINDER_TARGET_FORMAT,
                                             target.GetDim(0),
                                             target.GetDim(1),
                                             target.GetDim(2));

            ZACommons.GetBlocksOfType<IMyTextPanel>(targetGroup.Blocks).ForEach(block => {
                    ((IMyTextPanel)block).WritePublicText(targetString);
                });
        }
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:15,代码来源:combatranger.cs

示例2: AddGravityPrefab

        public static void AddGravityPrefab(Vector3D position, int radius, float strength, bool sync = true)
        {
            try
            {
                var prefab = MyDefinitionManager.Static.GetPrefabDefinition(PREFAB_NAME);

                if (prefab == null)
                {
                    Log.Error("Can't find prefab: " + PREFAB_NAME);
                    return;
                }

                if (prefab.CubeGrids == null)
                {
                    MyDefinitionManager.Static.ReloadPrefabsFromFile(prefab.PrefabPath);
                    prefab = MyDefinitionManager.Static.GetPrefabDefinition(PREFAB_NAME);
                }

                if (prefab.CubeGrids.Length == 0)
                {
                    Log.Error("Prefab is broken, does not have any grids in it!");
                    return;
                }

                MyObjectBuilder_CubeGrid builder = prefab.CubeGrids[0].Clone() as MyObjectBuilder_CubeGrid;
                builder.Name = PREFAB_NAME;
                builder.DestructibleBlocks = false;
                builder.PositionAndOrientation = new MyPositionAndOrientation(position, Vector3D.Forward, Vector3D.Up);

                MyObjectBuilder_GravityGeneratorSphere generator = builder.CubeBlocks[0] as MyObjectBuilder_GravityGeneratorSphere;
                generator.Radius = radius;
                generator.GravityAcceleration = strength * G;

                MyAPIGateway.Entities.RemapObjectBuilder(builder);
                IMyEntity ent = MyAPIGateway.Entities.CreateFromObjectBuilderAndAdd(builder);

                if (ent == null)
                {
                    Log.Error("Prefab created a null entity!");
                    return;
                }

                ent.Flags |= EntityFlags.Sync | EntityFlags.Save;

                if (sync)
                {
                    Log.Info("Spawned " + PREFAB_NAME + " and sent over network; pos=" + position + "; radius=" + radius + "; strength=" + strength);

                    // TODO remove temporary fix
                    StringBuilder data = new StringBuilder();

                    data.Append(0); // 0 = created
                    data.Append(';');
                    data.Append(position.GetDim(0));
                    data.Append(';');
                    data.Append(position.GetDim(1));
                    data.Append(';');
                    data.Append(position.GetDim(2));
                    data.Append(';');
                    data.Append(radius);
                    data.Append(';');
                    data.Append(strength);

                    MyAPIGateway.Multiplayer.SendMessageToOthers(PACKET_SYNC, Settings.encode.GetBytes(data.ToString()), true);

                    //MyAPIGateway.Multiplayer.SendEntitiesCreated(new List<MyObjectBuilder_EntityBase>() { ent as MyObjectBuilder_EntityBase });
                }
                else
                {
                    Log.Info("Spawned " + PREFAB_NAME + "; pos=" + position + "; radius=" + radius + "; strength=" + strength);
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
开发者ID:deimosx6,项目名称:NaturalGravity,代码行数:77,代码来源:NaturalGravity.cs

示例3: GetTargetRotorAngle

            public static double GetTargetRotorAngle(IMyTerminalBlock rotor, Vector3D targ, IMyTerminalBlock reference)
            {

                Vector3D targDir = Vector3D.Normalize(targ - reference.GetPosition());
                targDir = Vector3D.Normalize(Vector3D.Reject(targDir, rotor.WorldMatrix.Up));
                MatrixD state = MatrixD.Invert(rotor.WorldMatrix.GetOrientation());
                targDir = Vector3D.Transform(targDir, state);
                double angleAway = Math.Atan2(targDir.GetDim(2), targDir.GetDim(0));//Math.Atan2(Vector3D.Cross(targDir, rotor.WorldMatrix.Right).Length(), Vector3D.Dot(targDir, rotor.WorldMatrix.Right));                  
                double finalAng = angleAway;

                return finalAng;
            }
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:12,代码来源:Class1.cs

示例4: KepToCart

 public static void KepToCart(out Vector3D pos, out Vector3D vel, double a, double I, double w, double q, double e, double M, double E, double V, Planet planet)
 {//This doesn't work, feel free to try and fix it.
     
     double r = a*(1 - e * Math.Cos(E));
     Vector3D Op = new Vector3D(r*Math.Cos(V),r*Math.Sin(V),0);
     Vector3D Ov = new Vector3D(Math.Sqrt(planet.u * a) / r * -Math.Sin(E), Math.Sqrt(planet.u * a) / r*Math.Sqrt(1-Math.Pow(e,2))*Math.Cos(E),0);
     double Px = Op.GetDim(0) * (Math.Cos(w) * Math.Cos(q) - Math.Sin(w) * Math.Cos(I) * Math.Cos(q)) - Op.GetDim(1) * (Math.Sin(w) * Math.Cos(q) + Math.Cos(w) * Math.Cos(I) * Math.Sin(q));
     double Py = Op.GetDim(0) * (Math.Cos(w) * Math.Sin(q) + Math.Sin(w) * Math.Cos(I) * Math.Cos(q)) + Op.GetDim(1) * (Math.Cos(w) * Math.Cos(q) * Math.Cos(I) - Math.Sin(w) * Math.Sin(q));
     double Pz = Op.GetDim(0) * (Math.Sin(w) * Math.Sin(I)) + Op.GetDim(1) * (Math.Cos(w) * Math.Sin(I));
     double Vx = Ov.GetDim(0) * (Math.Cos(w) * Math.Cos(q) - Math.Sin(w) * Math.Cos(I) * Math.Cos(q)) - Ov.GetDim(1) * (Math.Sin(w) * Math.Cos(q) + Math.Cos(w) * Math.Cos(I) * Math.Sin(q));
     double Vy = Ov.GetDim(0) * (Math.Cos(w) * Math.Sin(q) + Math.Sin(w) * Math.Cos(I) * Math.Cos(q)) + Ov.GetDim(1) * (Math.Cos(w) * Math.Cos(q) * Math.Cos(I) - Math.Sin(w) * Math.Sin(q));
     double Vz = Ov.GetDim(0) * (Math.Sin(w) * Math.Sin(I)) + Ov.GetDim(1) * (Math.Cos(w) * Math.Sin(I));
     pos = new Vector3D(Px,Py,Pz);
     vel = new Vector3D(Vx,Vy,Vz);
     
 }
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:16,代码来源:Program.cs

示例5: CartToKep

        public void CartToKep(Vector3D pos, Vector3D vel)//This doesn't work, feel free to try and fix it.
        {
            this.pos = pos;
            this.vel = vel;
            en = vel.LengthSquared() / 2 - planet.u / pos.Length();
            a = Math.Abs(planet.u / (2 * en));
            h = Vector3D.Cross(pos, vel);
            E = Vector3D.Cross(vel, h) / planet.u - (pos / pos.Length());
            Console.WriteLine(E);
            e = E.Length();
            I = Math.Acos(h.GetDim(2) / h.Length());
            N = new Vector3D(-h.GetDim(1), h.GetDim(0), 0);
            if (N.GetDim(1) >= 0)
            {
                q = Math.Acos(N.GetDim(0) / N.Length());
                q = double.IsNaN(q) ? 0 : q;
            }
            else
            {
                q = 2 * Math.PI - Math.Acos(N.GetDim(0) / N.Length());
                q = double.IsNaN(q) ? 2*Math.PI : q;
            }
            
            n = Math.Sqrt(planet.u / Math.Pow(a, 3));
            if (q != 0)
            {
                w = E.GetDim(2) >= 0 ? Math.Acos(Vector3D.Dot(N, E) / (N.Length() * E.Length())) : Math.PI * 2 - Math.Acos(Vector3D.Dot(N, E) / (N.Length() * E.Length()));

            }
            else
            {
                double W=Math.Atan2(E.GetDim(1),E.GetDim(0));
                w = h.GetDim(2) < 0 ? 2*Math.PI-W:W;


            }

            if (double.IsNaN(w)) w = 0;
            if (w < 0) w += Math.PI * 2;
            epoch = DateTime.Now;
            if (E.Length() != 0)
            {
                v = Vector3D.Dot(pos, vel) >= 0 ? Math.Acos(Vector3D.Dot(E, pos) / (E.Length() * pos.Length())) : Math.PI * 2 - Math.Acos(Vector3D.Dot(E, pos) / (E.Length() * pos.Length()));
            }
            else
            {
                if (I != 0)
                {
                    v = Vector3D.Dot(N, vel) <= 0 ? Math.Acos(Vector3D.Dot(N, pos) / (N.Length() * pos.Length())) : Math.PI * 2 - Math.Acos(Vector3D.Dot(N, pos) / (N.Length() * pos.Length()));
                    Console.WriteLine(N);
                }
                else
                {
                    v = vel.GetDim(0) <= 0 ? Math.Acos(pos.GetDim(0) / (pos.Length())) : Math.PI * 2 - Math.Acos(pos.GetDim(0) / (pos.Length()));
                }
            }
            if (double.IsNaN(v)) v = 0;
            lastTa = v;
            double sinE = sin(a) * Math.Sqrt(1 - Math.Pow(e, 2)) / (1 + e * cos(a));
            double cosE = (e + cos(a)) / (1 + e * cos(a));
            double Ec = Math.Atan2(sinE, cosE);
            EC = 2 * Math.Atan(Math.Tan(v / 2) / Math.Sqrt(1 + e / 1 - e));
            EC = EC < 0 ? EC + Math.PI * 2 : EC;
            if (double.IsNaN(EC)) EC = 0;
            M = EC - e * Math.Sin(EC);
            lastM = M;
            Period = Math.PI * 2 * Math.Sqrt(Math.Pow(a,3)/planet.u);
        }
开发者ID:thedanieldude1,项目名称:DanielCode,代码行数:68,代码来源:Program.cs

示例6: plot

    public void plot(EasyBlocks blocks, double x, double y, double scale = 1.0, char brush = 'o', bool showBounds = true, char boundingBrush = '?')
    {
        VRageMath.Vector3D max = new Vector3D(this.screen.CubeGrid.Max);
        VRageMath.Vector3D min = new Vector3D(this.screen.CubeGrid.Min);
        VRageMath.Vector3D size = new Vector3D(max - min);

        int width = (int)size.GetDim(0);
        int height = (int)size.GetDim(1);
        int depth = (int)size.GetDim(2);

        int minX = (int)min.GetDim(0);
        int minY = (int)min.GetDim(1);
        int minZ = (int)min.GetDim(2);

        int maxX = (int)max.GetDim(0);
        int maxY = (int)max.GetDim(1);
        int maxZ = (int)max.GetDim(2);

        double s = (double)depth + 0.01;
        if(width > depth)
        {
            s = (double)width + 0.01;
        }

        if(showBounds)
        {
            box(x + -(((0 - (width / 2.0)) / s) * scale),
                y + -(((0 - (depth / 2.0)) / s) * scale),
                x + -(((maxX - minX - (width / 2.0)) / s) * scale),
                y + -(((maxZ - minZ - (depth / 2.0)) / s) * scale), boundingBrush);
        }

        for(int n = 0; n < blocks.Count(); n++)
        {
            var block = blocks.GetBlock(n);

            Vector3D pos = new Vector3D(block.Block.Position);

            pset(x + -((((double)(pos.GetDim(0) - minX - (width / 2.0)) / s)) * scale),
                 y + -((((double)(pos.GetDim(2) - minZ - (depth / 2.0)) / s)) * scale), brush);
        }
    }
开发者ID:jkeywo,项目名称:EasyAPI,代码行数:42,代码来源:EasyLCD.cs

示例7: SaveVector3D

 // Yes, I realize I could have just used Vector3D's ToString() and
 // TryParse(), but I'd rather not rely on them, especially ToString()
 private void SaveVector3D(Vector3D v, string[] output, int offset)
 {
     for (int i = 0; i < 3; i++)
     {
         output[offset+i] = v.GetDim(i).ToString();
     }
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:9,代码来源:losminer.cs


注:本文中的Vector3D.GetDim方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。