Ejemplo n.º 1
0
        public void APointRotatedAlongZWith270DegreesIsRight()
        {
            var pivot        = new float3(-1f, 0, 0);
            var rotatedPoint = RotationUtils.RotateAbout(pivot, 270, 1f);

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Less(pivot.x, rotatedPoint.z, "The rotated point is not to the right of the pivot!");
        }
Ejemplo n.º 2
0
        public void APointRotatedAlongZWith90DegreesIsLeft()
        {
            var pivot        = new float3(0, 0, 0);
            var rotatedPoint = RotationUtils.RotateAbout(pivot, 90, 1f);

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Greater(pivot.x, rotatedPoint.z, "The rotated point is not to the left of the pivot!");
        }
Ejemplo n.º 3
0
        public void APointRotatedAlongZWith180DegreesIsInBack()
        {
            var pivot        = new float3(0, 0, 1f);
            var rotatedPoint = RotationUtils.RotateAbout(pivot, 180f, 1f);

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Greater(pivot.z, rotatedPoint.z, "The rotated point is not behind the pivot!");
        }
Ejemplo n.º 4
0
        public void APointRotatedAlongZWithZeroDegreesIsInFront()
        {
            var pivot        = new float3(0, 0, 0);
            var rotatedPoint = RotationUtils.RotateAbout(pivot, 0f, 1f);

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Less(pivot.z, rotatedPoint.z, "The rotated point is not in front of the pivot!");
        }
Ejemplo n.º 5
0
        public void OneAndFourOClockMake120()
        {
            var fourOClock = RotationUtils.RotateAbout(float3.zero, 120, 1);
            var deg        = VectorUtils.AngleDeg(forward, fourOClock);

            Assert.AreEqual(120, deg, "Angle mismatch!");

            var rad = VectorUtils.Angle(forward, fourOClock);

            Assert.AreEqual(120f * ((float)math.PI) / 180f, rad, "Angle mismatch!");
        }
Ejemplo n.º 6
0
        public void APointRotatedAlongAnAxisAboutAPivotIsRotatedForwards()
        {
            var pivot     = new float3(0, 0, 0);
            var backwards = new float3(0, 0, -1f);

            var rotatedPoint = RotationUtils.RotateAbout(backwards, pivot, math.up(), 180f);

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Less(pivot.z, rotatedPoint.z, "The rotated point is not in front of the pivot!");
        }
Ejemplo n.º 7
0
        public void APointRotatedAlongAnAxisAboutAPivotIsRotatedBackwards()
        {
            var pivot   = new float3(0, 0, 0);
            var forward = new float3(0, 0, 1f);

            var rotatedPoint = RotationUtils.RotateAbout(forward, pivot, math.up(), 180f);

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Greater(pivot.z, rotatedPoint.z, "The rotated point is not behind the pivot!");
        }
Ejemplo n.º 8
0
        public void APointAlongZWithBackwardIsRotatedForwards()
        {
            var pivot    = new float3();
            var backward = new float3(0, 0, -1f);

            var rotatedPoint = RotationUtils.RotateAbout(pivot, backward, new float3(0, 180f, 0));

            Debug.LogFormat("<color=#00ff00ff>Pivot: {0}, Rotated Point: {1}</color>", pivot, rotatedPoint);

            Assert.Less(pivot.z, rotatedPoint.z, "The rotated point is not in front of the pivot!");
        }
Ejemplo n.º 9
0
        private void OnDrawGizmos()
        {
            Gizmos.color = pointColor;
            Gizmos.DrawSphere(point, radius);

            Gizmos.DrawLine(pivot, point);

            Gizmos.color = pivotColor;
            Gizmos.DrawSphere(pivot, radius);

            Gizmos.color = rotatedPointColor;
            var rotatedPoint = RotationUtils.RotateAbout(pivot, point, angle);

            Gizmos.DrawSphere(rotatedPoint, radius);
            Gizmos.DrawLine(pivot, rotatedPoint);
        }