public void ScalarMultiplicationTest() { var result = new XVector3(-2, -2, -2); Assert.True(result.x * a == result); Assert.True(a * result.x == result); }
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)); }
public void ArrayConstructor() { float[] arr = { 1, 1, 1 }; var b = new XVector3(arr); Assert.True(b == a); }
// 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()); }
// 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()); }
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; }
public void DistanceReturnsTheCartesianDistance() { Assert.AreEqual((float)Math.Sqrt(3), XVector3.Distance(new XVector3(), a)); }
public void DotProductTest() { var b = new XVector3(1, 2, 3); Assert.AreEqual(6, XVector3.Dot(b, a)); }
public void ScalarDivisionOnlyOnRightSide() { var result = new XVector3(0.5f, 0.5f, 0.5f); Assert.True(a / 2 == result); }
public void PointSubtractionTest() { var result = new XVector3(-1, -1, -1); Assert.True(result == a - a - a); }
public void PointAdditionTest() { var result = new XVector3(3, 3, 3); Assert.True(result == a + a + a); }
public static Vector3 PointToVector(XVector3 source) { return(new Vector3(source.x, source.y, source.z)); }