Exemple #1
0
        public static Matrix4f CreateScale(Vector3f scale)
        {
            Matrix4f m = Identity;

            m.Row0.x = scale.x; m.Row1.y = scale.y; m.Row2.z = scale.z;
            return(m);
        }
Exemple #2
0
        public static Matrix4f CreateScale(float scale)
        {
            Matrix4f m = Identity;

            m.Row0.x = scale; m.Row1.y = scale; m.Row2.z = scale;
            return(m);
        }
Exemple #3
0
        public Matrix4f ClearTranslation()
        {
            Matrix4f m = this;

            m.Row3.x = 0f; m.Row3.y = 0f; m.Row3.z = 0f;
            return(m);
        }
Exemple #4
0
        public static Matrix4f CreateTranslation(Vector3f v)
        {
            Matrix4f m = Identity;

            m.Row3.x = v.x; m.Row3.y = v.y; m.Row3.z = v.z;
            return(m);
        }
Exemple #5
0
        public Matrix4f Normalized()
        {
            Matrix4f m = this;

            m.Normalize();
            return(m);
        }
Exemple #6
0
 public bool EpsilonEqual(Matrix4f mat, float epsilon)
 {
     return(Row0.EpsilonEqual(mat.Row0, epsilon) &&
            Row1.EpsilonEqual(mat.Row1, epsilon) &&
            Row2.EpsilonEqual(mat.Row2, epsilon) &&
            Row3.EpsilonEqual(mat.Row3, epsilon));
 }
Exemple #7
0
        public Matrix4f ClearScale()
        {
            Matrix4f m       = this;
            Vector3f Row0xyz = new Vector3f(Row0.x, Row0.y, Row0.z).Normalized;
            Vector3f Row1xyz = new Vector3f(Row1.x, Row1.y, Row1.z).Normalized;
            Vector3f Row2xyz = new Vector3f(Row2.x, Row2.y, Row2.z).Normalized;

            m.Row0 = new Vector4f(Row0xyz.x, Row0xyz.y, Row0xyz.z, Row0.w);
            m.Row1 = new Vector4f(Row1xyz.x, Row1xyz.y, Row1xyz.z, Row0.w);
            m.Row2 = new Vector4f(Row2xyz.x, Row2xyz.y, Row2xyz.z, Row0.w);
            return(m);
        }
Exemple #8
0
        public Matrix4f ClearRotation()
        {
            Matrix4f m = this;

            Vector3f row0xyz = new Vector3f(Row0.x, Row0.y, Row0.z);
            Vector3f row1xyz = new Vector3f(Row1.x, Row1.y, Row1.z);
            Vector3f row2xyz = new Vector3f(Row2.x, Row2.y, Row2.z);

            m.Row0.x = row0xyz.Length;
            m.Row1.y = row1xyz.Length;
            m.Row2.z = row2xyz.Length;

            return(m);
        }
Exemple #9
0
        public static Matrix4f CreateRotationFromAxisAngle(Vector3f axis, float angle)
        {
            axis.Normalize();

            float cos = (float)Math.Cos(-angle);
            float sin = (float)Math.Sin(-angle);
            float t   = 1f - cos;

            float txx = t * axis.x * axis.x; float txy = t * axis.x * axis.y; float txz = t * axis.x * axis.z;
            float tyy = t * axis.y * axis.y; float tyz = t * axis.y * axis.z; float tzz = t * axis.z * axis.z;

            float sinx = sin * axis.x; float siny = sin * axis.y; float sinz = sin * axis.z;

            Matrix4f m = Identity;

            m.Row0 = new Vector4f(txx + cos, txy - sinz, txz + siny, 0f);
            m.Row1 = new Vector4f(txy + sinz, tyy + cos, tyz - sinx, 0f);
            m.Row2 = new Vector4f(txy - siny, tyz + sinx, tzz + cos, 0f);
            m.Row3 = new Vector4f(0f, 0f, 0f, 1f);
            return(m);
        }