Ejemplo n.º 1
0
        public void Create_IdentityMatrix_ReturnsIdentityMatrix()
        {
            var identityMatrix = Matrix3d.Identity();
            var expected       = new Matrix3d(1d, 0d, 0d, 0d, 1d, 0d, 0d, 0d, 1d);

            Assert.Equal(expected, identityMatrix);
        }
Ejemplo n.º 2
0
        public void IdentityMatrixTest()
        {
            Matrix3d   m = Matrix3d.Identity();
            Quaternion q = new Quaternion(m);

            Assert.AreEqual(q, new Quaternion(1, 0, 0, 0));
        }
Ejemplo n.º 3
0
        /// <summary> Initializes a new instance of the ScreenParameters class. </summary>
        public ViewportParameters()
        {
            Width  = 1d;
            Height = 1d;
            ProjectionPlaneDistance = 1d;

            CameraPosition = new Vector3d(0d, 0d, 0d);
            CameraRotation = Matrix3d.Identity();
        }
Ejemplo n.º 4
0
        public void CoordSystemTest()
        {
            Coord3d c1 = new Coord3d(new Point3d(), new[] { 2.0, 0.0, 0.0 }, new[] { 1.0, 1.0, 0.0 });

            Assert.IsTrue(c1.Axes == Matrix3d.Identity());

            c1 = new Coord3d(new Point3d(), new Vector3d(2, 0, 0), new Vector3d(0, 0, 5));
            c1.RotateDeg(new Vector3d(1, 0, 0), -90);
            Assert.IsTrue(c1.Axes == Matrix3d.Identity());
        }
Ejemplo n.º 5
0
        private Matrix3d Rotation_From_Two_Vector(Vector3d v1, Vector3d v2)
        {
            Vector3d w         = v1.Cross(v2).Normalized;
            Matrix3d K         = w.Make_Skew_Matrix();
            double   cos_theta = (v1.Dot(v2) / v1.Norm) / v2.Norm;
            double   theta     = Math.Acos(cos_theta); //theta값은 현재 라디안이다. C#의 삼각함수는 모두 라디안이 기준이다.

            Matrix3d R = Matrix3d.Identity() + Math.Sin(theta) * K + (1 - Math.Cos(theta)) * K * K;

            return(R);
        }
Ejemplo n.º 6
0
        public void RotationMatrixOrthogonalityTest()
        {
            Matrix3d r = Matrix3d.RotationMatrix(new Vector3d(1, 2, 3), PI / 2);

            Assert.IsTrue(r.Transpose() * r == Matrix3d.Identity());
        }
Ejemplo n.º 7
0
        public void MatrixInverseTest()
        {
            Matrix3d m = new Matrix3d(new[] { 1.0, 2.0, 3.0 }, new[] { 0.0, -4.0, 1.0 }, new[] { 0.0, 3.0, -1.0 });

            Assert.IsTrue(m.Inverse() * m == Matrix3d.Identity());
        }