Exemple #1
0
        public void RotateRightFlat(float deg, float dir)
        {
            Matrix3D rotMat = Rotate(m_zaxis, deg * dir);

            m_target = rotMat.Transform(m_target);
            m_right  = rotMat.Transform(m_right);
            m_up     = rotMat.Transform(m_up);

            /*m_target = m_lookat - m_eye;    // The "look-at" unit vector.
             * m_target.Normalize();
             * m_right = Vector3d.cross(m_target, m_up);*/
            UpdateView();
        }
Exemple #2
0
 void Rotate(Matrix3D rotmat)
 {
     for (int c = 0; c < m_lstpoints.Count; c++)
     {
         Point3d p  = (Point3d)m_lstpoints[c];
         Point3d p1 = rotmat.Transform(p);
         p.x = p1.x;
         p.y = p1.y;
         p.z = p1.z;
     }
 }
Exemple #3
0
 private void TransformRange(Matrix3D tMat, int startidx, int endidx)
 {
     for (int c = startidx; c < endidx; c++)
     {
         Point3d p3 = tMat.Transform(m_lstpoints[c]);
         m_lstpoints[c].x = p3.x;
         m_lstpoints[c].y = p3.y;
         m_lstpoints[c].z = p3.z;
     }
     // Update(); // not necessary
     m_listid = -1; // regenerate the list id
 }
Exemple #4
0
        // rotate eye deg degrees arround rotAxis pivoting at target (m_lookat)
        protected Matrix3D Rotate(Vector3d rotAxis, float deg)
        {
            float    rad    = deg2rad * deg;
            float    c      = (float)Math.Cos(rad);
            float    s      = (float)Math.Sin(rad);
            float    t      = 1.0f - c;
            float    x      = rotAxis.x;
            float    y      = rotAxis.y;
            float    z      = rotAxis.z;
            Matrix3D rotMat = new Matrix3D(new float [] {
                t *x *x + c, t *x *y - s *z, t *x *z + s *y, 0,
                t *x *y + s *z, t *y *y + c, t *y *z - s *x, 0,
                t *x *z - s *y, t *y *z + s *x, t *z *z + c, 0,
                0, 0, 0, 1
            });

            m_eye = rotMat.Transform(m_eye - m_lookat);
            m_eye = m_eye + m_lookat;
            return(rotMat);
        }
Exemple #5
0
        public void Rotate(float x, float y, float z)
        {
            Point3d center = CalcCenter();

            Translate((float)-center.x, (float)-center.y, (float)-center.z);

            Matrix3D rotmat = new Matrix3D();

            rotmat.Identity();
            rotmat.Rotate(x, y, z);
            for (int c = 0; c < m_lstpoints.Count; c++)
            {
                Point3d p  = (Point3d)m_lstpoints[c];
                Point3d p1 = rotmat.Transform(p);
                p.x = p1.x;
                p.y = p1.y;
                p.z = p1.z;
            }
            Translate((float)center.x, (float)center.y, (float)center.z);
        }
        public void Rotate(float x, float y, float z) 
        {
            Point3d center = CalcCenter();
            Translate((float)-center.x, (float)-center.y, (float)-center.z);

            Matrix3D rotmat = new Matrix3D();
            rotmat.Identity();
            rotmat.Rotate(x, y, z);
            for(int c = 0; c< m_lstpoints.Count;c++)            
            {
                Point3d p = (Point3d)m_lstpoints[c];
                Point3d p1 = rotmat.Transform(p);
                p.x = p1.x;
                p.y = p1.y;
                p.z = p1.z;
            }
            Translate((float)center.x, (float)center.y, (float)center.z);
        }
        // rotate eye deg degrees arround rotAxis pivoting at target (m_lookat)
        protected Matrix3D Rotate(Vector3d rotAxis, float deg)
        {
            float rad = deg2rad * deg;
            float c = (float)Math.Cos(rad);
            float s = (float)Math.Sin(rad);
            float t = 1.0f - c;
            float x = rotAxis.x;
            float y = rotAxis.y;
            float z = rotAxis.z;
            Matrix3D rotMat= new Matrix3D(new float [] {
                t*x*x+c, t*x*y-s*z, t*x*z+s*y, 0,
                t*x*y+s*z, t*y*y+c, t*y*z-s*x, 0,
                t*x*z-s*y, t*y*z+s*x, t*z*z+c, 0,
                0,0,0,1
            });

            m_eye = rotMat.Transform(m_eye - m_lookat);
            m_eye = m_eye + m_lookat;
            return rotMat;
        }
 private void TransformRange(Matrix3D tMat, int startidx, int endidx)
 {
     for (int c = startidx; c < endidx; c++)
     {
         Point3d p3 = tMat.Transform(m_lstpoints[c]);
         m_lstpoints[c].x = p3.x;
         m_lstpoints[c].y = p3.y;
         m_lstpoints[c].z = p3.z;
     }
        // Update(); // not necessary
     m_listid = -1; // regenerate the list id
 }
Exemple #9
0
 void Rotate(Matrix3D rotmat)
 {
     for (int c = 0; c < m_lstpoints.Count; c++)
     {
         Point3d p = (Point3d)m_lstpoints[c];
         Point3d p1 = rotmat.Transform(p);
         p.x = p1.x;
         p.y = p1.y;
         p.z = p1.z;
     }
 }