Esempio n. 1
0
        /// <summary>
        /// Rotates around x,y and z axis by the given amount in Degrees
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        public static Matrix3d RotationXYZDegrees(this Matrix3d mat, double x, double y, double z)
        {
            Matrix3d Rx = Matrix3d.CreateRotationX(Convert.ToSingle(Math.PI * x / 180));
            Matrix3d Ry = Matrix3d.CreateRotationY(Convert.ToSingle(Math.PI * y / 180));
            Matrix3d Rz = Matrix3d.CreateRotationZ(Convert.ToSingle(Math.PI * z / 180));

            Rx = Matrix3d.Mult(Rx, Ry);
            Rx = Matrix3d.Mult(Rx, Rz);

            return(Rx);
        }
Esempio n. 2
0
        /// <summary>
        /// Rotates around x,y and z axis by the given amount in radiants
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        /// <returns></returns>
        public static Matrix3d RotationXYZRadiants(this Matrix3d mat, double x, double y, double z)
        {
            Matrix3d Rx = Matrix3d.CreateRotationX(x);
            Matrix3d Ry = Matrix3d.CreateRotationY(y);
            Matrix3d Rz = Matrix3d.CreateRotationZ(z);

            Rx = Matrix3d.Mult(Rx, Ry);
            Rx = Matrix3d.Mult(Rx, Rz);

            return(Rx);
        }
Esempio n. 3
0
        public static Matrix3d RotateSome(this Matrix3d mat)
        {
            Matrix3d Rx = Matrix3d.CreateRotationX(90);
            Matrix3d Ry = Matrix3d.CreateRotationY(124);
            Matrix3d Rz = Matrix3d.CreateRotationZ(-274);

            Rx = Matrix3d.Mult(Rx, Ry);
            Rx = Matrix3d.Mult(Rx, Rz);

            return(Rx);
        }
Esempio n. 4
0
        public static Matrix3d Rotation60Degrees(this Matrix3d mat)
        {
            Matrix3d Rx = Matrix3d.CreateRotationX(60);
            Matrix3d Ry = Matrix3d.CreateRotationY(60);
            Matrix3d Rz = Matrix3d.CreateRotationZ(60);

            Rx = Matrix3d.Mult(Rx, Ry);
            Rx = Matrix3d.Mult(Rx, Rz);

            return(Rx);
        }
Esempio n. 5
0
        public static double Test2_RotationX30Degrees(ref PointCloudVertices myPCLTarget, ref PointCloudVertices myPCLSource, ref PointCloudVertices myPCLResult)
        {
            //myPCLTarget = Vertices.CreateSomePoints();
            myPCLTarget = PointCloudVertices.CreateCube_Corners(50);
            myPCLSource = PointCloudVertices.CloneVertices(myPCLTarget);

            Matrix3d R = Matrix3d.CreateRotationX(30);

            PointCloudVertices.Rotate(myPCLSource, R);


            myPCLResult = IterativeClosestPointTransform.Instance.PerformICP(myPCLSource, myPCLTarget);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Esempio n. 6
0
        public static double Test2_RotationX30Degrees(ref List <Vertex> myVerticesTarget, ref List <Vertex> myVerticesSource, ref List <Vertex> myVerticesResult)
        {
            //myVerticesTarget = Vertices.CreateSomePoints();
            myVerticesTarget = Vertices.CreateCube_Corners(50);
            myVerticesSource = VertexUtils.CloneListVertex(myVerticesTarget);

            Matrix3d R = Matrix3d.CreateRotationX(30);

            VertexUtils.RotateVertices(myVerticesSource, R);


            myVerticesResult = IterativeClosestPointTransform.Instance.PerformICP(myVerticesTarget, myVerticesSource);
            return(IterativeClosestPointTransform.Instance.MeanDistance);
        }
Esempio n. 7
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            double displacement = 500;

            base.OnUpdateFrame(e);
            Planet.Update(CamPos);

            if (Focused)
            {
                var Keyboard = OpenTK.Input.Keyboard.GetState();

                Matrix4d rot = Matrix4d.CreateFromQuaternion(CamRot);

                Vector3d left  = rot.Row0.Xyz;
                Vector3d up    = rot.Row1.Xyz;
                Vector3d front = rot.Row2.Xyz;;

                if (Keyboard[OpenTK.Input.Key.ShiftLeft])
                {
                    displacement *= 100;
                }

                if (Keyboard[OpenTK.Input.Key.W])
                {
                    CamPos -= front * displacement;
                }
                if (Keyboard[OpenTK.Input.Key.S])
                {
                    CamPos += front * displacement;
                }
                if (Keyboard[OpenTK.Input.Key.D])
                {
                    CamPos += left * displacement;
                }
                if (Keyboard[OpenTK.Input.Key.A])
                {
                    CamPos -= left * displacement;
                }
                if (Keyboard[OpenTK.Input.Key.Q])
                {
                    CamPos -= up * displacement;
                }
                if (Keyboard[OpenTK.Input.Key.E])
                {
                    CamPos += up * displacement;
                }


                Vector3d NewCamRot = new Vector3d();
                if (Keyboard[OpenTK.Input.Key.I])
                {
                    NewCamRot.X -= 0.1;
                }
                if (Keyboard[OpenTK.Input.Key.K])
                {
                    NewCamRot.X += 0.1;
                }
                if (Keyboard[OpenTK.Input.Key.J])
                {
                    NewCamRot.Y -= 0.1;
                }
                if (Keyboard[OpenTK.Input.Key.L])
                {
                    NewCamRot.Y += 0.1;
                }
                if (Keyboard[OpenTK.Input.Key.U])
                {
                    NewCamRot.Z -= 0.1;
                }
                if (Keyboard[OpenTK.Input.Key.O])
                {
                    NewCamRot.Z += 0.1;
                }

                if (Keyboard[OpenTK.Input.Key.Space])
                {
                    CamPos = DefaultPos;
                    CamRot = Quaterniond.Identity;
                }

                if (Keyboard[OpenTK.Input.Key.R])
                {
                    Shader.Recompile();
                }

                if (Keyboard[OpenTK.Input.Key.X])
                {
                    if (IsLine)
                    {
                        GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                        IsLine = false;
                    }
                    else
                    {
                        GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
                        IsLine = true;
                    }
                }

                if (Keyboard[OpenTK.Input.Key.Z])
                {
                    Integrator.Reset();
                    Planet.Layers[0].RegeneratePlanet();
                }

                if (Keyboard[OpenTK.Input.Key.Escape])
                {
                    Exit();
                }

                Frustum.SetCamDef(CamPos, CamPos + front, up);

                CamRot *= Quaterniond.FromMatrix(Matrix3d.CreateRotationX(NewCamRot.X) * Matrix3d.CreateRotationY(NewCamRot.Y) * Matrix3d.CreateRotationZ(NewCamRot.Z));
            }
        }