public AngleBetweenDouble()
        {
            var rnd = new RandomSystem(1);

            A.SetByIndex(i => rnd.UniformV3dDirection());
            angles.SetByIndex(i => rnd.UniformDouble() * (double)Constant.Pi);
            B.SetByIndex(i =>
            {
                V3d v;
                do
                {
                    v = rnd.UniformV3dDirection();
                }while (v.Dot(A[i]).IsTiny());

                V3d axis = v.Cross(A[i]).Normalized;

                return(M44d.Rotation(axis, angles[i]).TransformDir(A[i]));
            });
        }
Esempio n. 2
0
        public static void Rot3dInvTransformTest()
        {
            var rnd = new RandomSystem(1);

            for (int i = 0; i < 10000; i++)
            {
                var v    = rnd.UniformV3d();
                var axis = rnd.UniformV3dDirection();
                var ang  = rnd.UniformDouble();
                var rot  = Rot3d.Rotation(axis, ang);

                var test1 = InvTransformUsingM33d(rot, v);
                var test2 = rot.InvTransform(v);
                var test3 = InvTransformUsingQuaternion(rot, v);
                var test4 = InvTransformUsingQuaternionOpt(rot, v);

                Assert.IsTrue(test1.ApproximateEquals(test2, 1e-5));
                Assert.IsTrue(test1.ApproximateEquals(test3, 1e-5));
                Assert.IsTrue(test1.ApproximateEquals(test4, 1e-5));
            }
        }
Esempio n. 3
0
 public static Rot3d GetRandomRot3(RandomSystem rnd)
 => Rot3d.Rotation(rnd.UniformV3dDirection(), rnd.UniformDouble() * Constant.PiTimesTwo);
Esempio n. 4
0
 private static V3d RndAxis(RandomSystem rnd)
 => rnd.UniformV3dDirection();