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


C# Plane.GetVelocity方法代码示例

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


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

示例1: TestPlaneConstructor

    public static void TestPlaneConstructor()
    {
        PlaneAttributes atts = new PlaneAttributes("badger50", 1, 5, 3, 7, 2000);
        Plane p = new Plane("acas-1200-badger50", atts);

        //A plane should have anything assigned to it in the constructor reflected in it immediately.
        p.attributes.maxHeight.ShouldBe(2000);
        p.attributes.planeModelGUID.ShouldBe("badger50");
        p.attributes.planeHeight.ShouldBe(3);
        p.attributes.planeWidth.ShouldBe(5);
        p.attributes.planeLength.ShouldBe(7);
        p.attributes.planeClass.ShouldBe(1);

        //A new plane should have no position data within it.
        p.GetPositionCount().ShouldBe(0);

        //A new plane with no position data should have a 'zero' velocity
        p.IsClass(p.attributes.planeClass).ShouldBe(true);
        Vector3d vel = p.GetVelocity();
        vel.x.ShouldBe(0, .01);
        vel.y.ShouldBe(0, .01);
        vel.z.ShouldBe(0, .01);

        //Getting position from a newly constructed plane (with no position data)
        //should cause a NotSupportedException
        Exception ex = null;
        try {
            Vector3d pos = p.GetPosition();
        } catch (Exception e) {
            ex = e;
        }
        ex.ShouldNotBeNull();
        ex.GetType().ShouldBe(typeof(NotSupportedException));
    }
开发者ID:2015SoftwarePrinciples,项目名称:GTKTestWindow,代码行数:34,代码来源:ObjectTests.cs

示例2: createTestSet

    //Method for Initializing an array of planes for testing
    public static Plane[][] createTestSet()
    {
        //TBD: Add some plane data for 'successful' collisions tests here
        //The test data needs to be pretty precise (down to the .001 lat/long and a number of entries over a few seconds)
        PlaneAttributes atts = new PlaneAttributes("default", 1, 150, 150, 150, 3000);
        long zeroTime = 0x7000000010000000;
        double denverLat = 39.7392;
        double denverLong = 104.9903;

        double sydneyLat = -33.8830555556;
        double sydneyLong = 151.216666667;

        double moscowLat = 55.7522222;
        double moscowLong = 37.6155556;

        //head on collision
        Plane a = new Plane("a", atts);
        Plane aa = new Plane("aa", atts);

        for (int i = 0; i < 100; i++) {
            a.AddPosition(new GPSData(denverLat, denverLong + .0223 - i * .0001, 2000, zeroTime + 1000 * i));
            aa.AddPosition(new GPSData(denverLat, denverLong - .0223 + i * .0001, 2000, zeroTime + 1000 * i));
        }

        Console.WriteLine(a.GetPosition() + " : " +  a.GetVelocity());
        Console.WriteLine(aa.GetPosition() + " : " +  aa.GetVelocity());

        //right angle collision
        Plane b = new Plane("b", atts);
        Plane bb = new Plane("bb", atts);

        for (int i = 0; i < 100; i++) {
            b.AddPosition(new GPSData(sydneyLat - .0223 + i * .0001, sydneyLong, 2000, zeroTime + 1000 * i));
            bb.AddPosition(new GPSData(sydneyLat, sydneyLong - .0223 + i * .0001, 2000, zeroTime + 1000 * i));
        }

        //Collision from behind
        Plane c = new Plane("c", atts);
        Plane cc = new Plane("cc", atts);

        for (int i = 0; i < 100; i++) {
            c.AddPosition(new GPSData(moscowLat, moscowLong - .0200 + i * .0002, 2000, zeroTime + 1000 * i));
            cc.AddPosition(new GPSData(moscowLat, moscowLong - .0400 + i * .00035, 2000, zeroTime + 1000 * i));
        }

        Plane[][] planeArray = new Plane[][] {
            new Plane[] { a, aa },
            new Plane[] { b, bb },
            new Plane[] { c, cc }
        };

        return planeArray;
    }
开发者ID:2015SoftwarePrinciples,项目名称:GTKTestWindow,代码行数:54,代码来源:CollisionTests.cs

示例3: CheckCollision

    public static bool CheckCollision(Plane a, Plane b, out float time)
    {
        //Saving position and velocity of 2 planes to variables
        Vector3d aPos = a.GetPosition();
        Vector3d aVel = a.GetVelocity();
        Vector3d bPos = b.GetPosition();
        Vector3d bVel = b.GetVelocity();

        //Calculating Radius of each plane. Making R variable to save sum of radius
        double r1 = Math.Max (Math.Max(a.attributes.planeHeight, a.attributes.planeWidth), a.attributes.planeLength);
        double r2 = Math.Max (Math.Max(b.attributes.planeHeight, b.attributes.planeWidth), b.attributes.planeLength);
        double R = r1 + r2;

        return CheckCollision(aPos, aVel, bPos, bVel, R, out time);
    }
开发者ID:2015SoftwarePrinciples,项目名称:GTKTestWindow,代码行数:15,代码来源:CollisionDetection.cs


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