Beispiel #1
0
        public void VertexTransformation()
        {
            var directionHelper = DirectionRotatorExtensions.Create();

            //Should rotate 90 degrees about the x axis
            var quat = directionHelper.GetRotationQuat(new VoxelRotation()
            {
                x = 1
            });

            var testVector = new float3(0, 1, 0);
            //Should become 0,0,1
            var result = math.round(math.mul(quat, testVector));

            Assert.AreEqual(new float3(0, 0, 1), result);

            //Should rotate 180 degress around x then 90 around z
            quat = directionHelper.GetRotationQuat(new VoxelRotation()
            {
                x = 2, z = 1
            });
            result = math.round(math.mul(quat, testVector));
            Assert.AreEqual(new float3(1, 0, 0), result);


            directionHelper.Dispose();
        }
Beispiel #2
0
        public void Inverse()
        {
            using (var directionHelper = DirectionRotatorExtensions.Create())
            {
                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        for (int k = 0; k < 4; k++)
                        {
                            var rotation = new VoxelRotation()
                            {
                                x = i, y = j, z = k
                            };
                            var testDirection = Direction.north;

                            var thereAndBackAgain = directionHelper.GetDirectionBeforeRotation(directionHelper.GetDirectionAfterRotation(testDirection, rotation), rotation);

                            Assert.AreEqual(testDirection, thereAndBackAgain, $"Failed to invert rotation {rotation}");
                        }
                    }
                }
            }
        }