Ejemplo n.º 1
0
        static Vector3D NextOrthogonalVector3D(Vector3D v)
        {
            var a0 = v.X == 0 ? Rotation3DHelper.UnitX : new Vector3D(v.Y, -v.X, 0);

            a0.Normalize();
            var angle = RandomHelper.NextDouble(-π, π);
            var q     = Rotation3DHelper.CreateQuaternionInRadians(v, angle);

            return(a0.Multiply(q));
        }
Ejemplo n.º 2
0
        public void PointsToPoints_Many()
        {
            for (var i = 0; i < 1000; i++)
            {
                var rotatedUnitZ = NextVector3D();
                var rotatedUnitY = NextOrthogonalVector3D(rotatedUnitZ);

                var m = Rotation3DHelper.ToEulerAngles(rotatedUnitZ, rotatedUnitY).ToMatrix3D();
                AssertVector3D(rotatedUnitZ, Rotation3DHelper.UnitZ * m);
                AssertVector3D(rotatedUnitY, Rotation3DHelper.UnitY * m);
            }
        }
Ejemplo n.º 3
0
        static void ToEulerAngles_One(EulerAngles expected, Vector3D rotatedUnitZ, Vector3D rotatedUnitY)
        {
            var actual = Rotation3DHelper.ToEulerAngles(rotatedUnitZ, rotatedUnitY);

            AssertEulerAngles(expected, actual);
        }
Ejemplo n.º 4
0
 static Quaternion NextQuaternion() => Rotation3DHelper.CreateQuaternionInRadians(
     new Vector3D(RandomHelper.NextDouble(-1, 1), RandomHelper.NextDouble(-1, 1), RandomHelper.NextDouble(-1, 1)),
     RandomHelper.NextDouble(-7, 7));