public static Vector3 VectorTransform(Vector3 v, Transform3 m)
 {
     return(new Vector3(
                v[0] * m[0][0] + v[1] * m[1][0] + v[2] * m[2][0],
                v[0] * m[0][1] + v[1] * m[1][1] + v[2] * m[2][1],
                v[0] * m[0][2] + v[1] * m[1][2] + v[2] * m[2][2]));
 }
 public Matrix4(Transform3 m) : this(
         new Vector4(m[0], 0.0f),
         new Vector4(m[1], 0.0f),
         new Vector4(m[2], 0.0f),
         new Vector4(m[3], 1.0f))
 {
 }
 public static Transform3 PostScale(Transform3 m, float scaleX, float scaleY, float scaleZ)
 {
     return(new Transform3(
                m[0][0] * scaleX, m[0][1] * scaleY, m[0][2] * scaleZ,
                m[1][0] * scaleX, m[1][1] * scaleY, m[1][2] * scaleZ,
                m[2][0] * scaleX, m[2][1] * scaleY, m[2][2] * scaleZ,
                m[3][0] * scaleX, m[3][1] * scaleY, m[3][2] * scaleZ));
 }
 public static Transform3 PostTrans(Transform3 m, float transX, float transY, float transZ)
 {
     return(new Transform3(
                m[0][0], m[0][1], m[0][2],
                m[1][0], m[1][1], m[1][2],
                m[2][0], m[2][1], m[2][2],
                m[3][0] + transX, m[3][1] + transY, m[3][2] + transZ));
 }
 public static Transform3 PreScale(float scaleX, float scaleY, float scaleZ, Transform3 m)
 {
     return(new Transform3(
                m[0][0] * scaleX, m[0][1] * scaleX, m[0][2] * scaleX,
                m[1][0] * scaleY, m[1][1] * scaleY, m[1][2] * scaleY,
                m[2][0] * scaleZ, m[2][1] * scaleZ, m[2][2] * scaleZ,
                m[3][0], m[3][1], m[3][2]));
 }
 public static Transform3 PreTrans(float transX, float transY, float transZ, Transform3 m)
 {
     return(new Transform3(
                m[0][0], m[0][1], m[0][2],
                m[1][0], m[1][1], m[1][2],
                m[2][0], m[2][1], m[2][2],
                m[3][0] + m[0][0] * transX + m[1][0] * transY + m[2][0] * transZ,
                m[3][1] + m[0][1] * transX + m[1][1] * transY + m[2][1] * transZ,
                m[3][2] + m[0][2] * transX + m[1][2] * transY + m[2][2] * transZ));
 }
        public static Transform3 Inverse(Transform3 m)
        {
            Matrix3 rotInv = Matrix3.Inverse(m.GetUpper3x3());
            Vector3 trans  = new Vector3(
                -m[3][0] * rotInv[0][0] - m[3][1] * rotInv[1][0] - m[3][2] * rotInv[2][0],
                -m[3][0] * rotInv[0][1] - m[3][1] * rotInv[1][1] - m[3][2] * rotInv[2][1],
                -m[3][0] * rotInv[0][2] - m[3][1] * rotInv[1][2] - m[3][2] * rotInv[2][2]);

            return(new Transform3(rotInv[0], rotInv[1], rotInv[2], trans));
        }
        public static Transform3 PostRotZ(Transform3 m, float radians)
        {
            float cs = (float)System.Math.Cos(radians);
            float sn = (float)System.Math.Sin(radians);

            return(new Transform3(
                       m[0][0] * cs - m[0][1] * sn, m[0][1] * cs + m[0][0] * sn, m[0][2],
                       m[1][0] * cs - m[1][1] * sn, m[1][1] * cs + m[1][0] * sn, m[1][2],
                       m[2][0] * cs - m[2][1] * sn, m[2][1] * cs + m[2][0] * sn, m[2][2],
                       m[3][0] * cs - m[3][1] * sn, m[3][1] * cs + m[3][0] * sn, m[3][2]));
        }
Ejemplo n.º 9
0
        public static Transform3 PreRotZ(float radians, Transform3 m)
        {
            float cs = (float)Math.Cos(radians);
            float sn = (float)Math.Sin(radians);

            return(new Transform3(
                       m[0][0] * cs + m[1][0] * sn, m[0][1] * cs + m[1][1] * sn, m[0][2] * cs + m[1][2] * sn,
                       m[1][0] * cs - m[0][0] * sn, m[1][1] * cs - m[0][1] * sn, m[1][2] * cs - m[0][2] * sn,
                       m[2][0], m[2][1], m[2][2],
                       m[3][0], m[3][1], m[3][2]));
        }
 public static void Decompose(Transform3 t,
                              out float scaleX, out float scaleY, out float scaleZ,
                              out float shearXY, out float shearXZ, out float shearZY,
                              out float rotateX, out float rotateY, out float rotateZ,
                              out float transX, out float transY, out float transZ)
 {
     Matrix3.Decompose(t.GetUpper3x3(),
                       out scaleX, out scaleY, out scaleZ,
                       out shearXY, out shearXZ, out shearZY,
                       out rotateX, out rotateY, out rotateZ);
     transX = t[3][0];
     transY = t[3][1];
     transZ = t[3][2];
 }
 public bool Equals(Transform3 m)
 {
     return(this == m);
 }