コード例 #1
0
        public void ScalarMultiplicationTest()
        {
            var result = new XVector3(-2, -2, -2);

            Assert.True(result.x * a == result);
            Assert.True(a * result.x == result);
        }
コード例 #2
0
        public void NormalizeReturnsUnitVector()
        {
            var result = new XVector3(1 / (float)Math.Sqrt(3), 1 / (float)Math.Sqrt(3), 1 / (float)Math.Sqrt(3));

            Assert.True(result == a.normalized);
            Assert.True(result == XVector3.Normalize(a));
        }
コード例 #3
0
        public void ArrayConstructor()
        {
            float[] arr = { 1, 1, 1 };
            var     b   = new XVector3(arr);

            Assert.True(b == a);
        }
コード例 #4
0
    // we determine the lane by considering the angle between the previous target
    // and the 2nd next waypoint:
    // (2) ---- (3)
    //  |
    //  |
    // (1)
    // when travelling (1) -> (2), we'll need to keep to the right-most lane as we'll be turning right.
    private int DetermineLane(LaneConfiguration lc, Vector3 direction, out Vector3 willTurn)
    {
        // there is no previous waypoint
        willTurn = Vector3.zero;
        if (headingToIndex == 0)
        {
            return(1);
        }

        // if there is no next
        if (headingToIndex + 1 == path.Length)
        {
            return(1);
        }

        var previous = path[headingToIndex - 1].transform.position;
        var next     = path[headingToIndex + 1].transform.position;

        var heading   = next - previous;
        var distance  = heading.magnitude;
        var targetDir = heading / distance; // This is now the normalized direction.

        var relativeDir = XVector3.AngleDir(direction, targetDir, Vector3.up);

        willTurn = relativeDir;

        return(relativeDir == Vector3.left ? lc.LeftMost() : lc.RightMost());
    }
コード例 #5
0
ファイル: SpawnPoint.cs プロジェクト: GPIG-C-2017/prototype
    // Use this for initialization
    void Start()
    {
        spawnDelay = Mathf.Pow(SpawnsPerMinute * GlobalRatio / 60f, -1);

        directionToNeighbour = XVector3.Direction(wp.transform.position, wp.Neighbours[0].transform.position);
        lc = TCA.GetLaneConfiguration(wp, wp.Neighbours[0]);

        InitLanes();

        StartCoroutine(WaitSpawn());
    }
コード例 #6
0
 public CSquareFootprint(XReal xMin, XReal xMax, XReal zMin, XReal zMax)
 {
     Size      = new XVector3(xMax - xMin, 0, zMax - zMin);
     Offset    = new XVector3((xMax + xMin) / 2, 0, (zMax + zMin) / 2);
     Transform = XMatrix.Identity;
 }
コード例 #7
0
 public void DistanceReturnsTheCartesianDistance()
 {
     Assert.AreEqual((float)Math.Sqrt(3), XVector3.Distance(new XVector3(), a));
 }
コード例 #8
0
        public void DotProductTest()
        {
            var b = new XVector3(1, 2, 3);

            Assert.AreEqual(6, XVector3.Dot(b, a));
        }
コード例 #9
0
        public void ScalarDivisionOnlyOnRightSide()
        {
            var result = new XVector3(0.5f, 0.5f, 0.5f);

            Assert.True(a / 2 == result);
        }
コード例 #10
0
        public void PointSubtractionTest()
        {
            var result = new XVector3(-1, -1, -1);

            Assert.True(result == a - a - a);
        }
コード例 #11
0
        public void PointAdditionTest()
        {
            var result = new XVector3(3, 3, 3);

            Assert.True(result == a + a + a);
        }
コード例 #12
0
ファイル: BoxBuilder.cs プロジェクト: muramasa2402/DroNeS-LLV
 public static Vector3 PointToVector(XVector3 source)
 {
     return(new Vector3(source.x, source.y, source.z));
 }