Ejemplo n.º 1
0
        //                  -1
        // V'=q*V*q     ,
        public void Rotate(Point3d pt)
        {
            this.Normalise();
            Quaternion q1 = this.Copy();
            q1.Conjugate();

            Quaternion qNode = new Quaternion(0, pt.X, pt.Y, pt.Z);
            qNode = this * qNode * q1;
            pt.X = qNode.X;
            pt.Y = qNode.Y;
            pt.Z = qNode.Z;
        }
Ejemplo n.º 2
0
        private void RotateNegativeZ(object sender, EventArgs e)
        {
            cubeZ        -= 5;
            labelCrZ.Text = cubeZ.ToString();
            YLScsDrawing.Drawing3d.Quaternion q = new YLScsDrawing.Drawing3d.Quaternion();
            q.FromAxisAngle(new YLScsDrawing.Drawing3d.Vector3d(0, 0, 1), -5 * Math.PI / 180.0);
            cub.RotateAt(cub.Center, q);

            GetLocalAxis();

            Invalidate();
        }
Ejemplo n.º 3
0
        private void RotatePositiveX(object sender, EventArgs e)
        {
            cubeX        += 5;
            labelCrX.Text = cubeX.ToString();
            YLScsDrawing.Drawing3d.Quaternion q = new YLScsDrawing.Drawing3d.Quaternion();
            q.FromAxisAngle(new YLScsDrawing.Drawing3d.Vector3d(1, 0, 0), 5 * Math.PI / 180.0);
            cub.RotateAt(cub.Center, q);

            GetLocalAxis();

            Invalidate();
        }
Ejemplo n.º 4
0
 public void Rotate(Point3d[] nodes)
 {
     this.Normalise();
     Quaternion q1 = this.Copy();
     q1.Conjugate();
     for (int i = 0; i < nodes.Length; i++)
     {
         Quaternion qNode = new Quaternion(0, nodes[i].X, nodes[i].Y, nodes[i].Z);
         qNode = this * qNode * q1;
         nodes[i].X = qNode.X;
         nodes[i].Y = qNode.Y;
         nodes[i].Z = qNode.Z;
     }
 }
Ejemplo n.º 5
0
 public void Multiply(Quaternion q)
 {
     this *= q;
 }
Ejemplo n.º 6
0
        static Quaternion new_rotate_euler(double heading, double attitude, double bank)
        {
            Quaternion Q = new Quaternion();
            double c1 = Math.Cos(heading / 2);
            double s1 = Math.Sin(heading / 2);
            double c2 = Math.Cos(attitude / 2);
            double s2 = Math.Sin(attitude / 2);
            double c3 = Math.Cos(bank / 2);
            double s3 = Math.Sin(bank / 2);

            Q.W = c1 * c2 * c3 - s1 * s2 * s3;
            Q.X = s1 * s2 * c3 + c1 * c2 * s3;
            Q.Y = s1 * c2 * c3 + c1 * s2 * s3;
            Q.Z = c1 * s2 * c3 - s1 * c2 * s3;
            return Q;
        }