Ejemplo n.º 1
0
        public Matrix4f Transpose()
        {
            Matrix4f res = new Matrix4f();

            res.values[m00] = values[m00];
            res.values[m01] = values[m10];
            res.values[m02] = values[m20];
            res.values[m03] = values[m30];

            res.values[m10] = values[m01];
            res.values[m11] = values[m11];
            res.values[m12] = values[m21];
            res.values[m13] = values[m31];

            res.values[m20] = values[m02];
            res.values[m21] = values[m12];
            res.values[m22] = values[m22];
            res.values[m23] = values[m32];

            res.values[m30] = values[m03];
            res.values[m31] = values[m13];
            res.values[m32] = values[m23];
            res.values[m33] = values[m33];

            return(res);
        }
Ejemplo n.º 2
0
        public Matrix4f Invert()
        {
            Matrix4f newMat = new Matrix4f(this);

            newMat.InvertStore();
            return(newMat);
        }
Ejemplo n.º 3
0
        public Matrix4f Multiply(float scalar)
        {
            Matrix4f newMat = new Matrix4f();

            for (int i = 0; i < values.Length; i++)
            {
                newMat.values[i] = this.values[i] * scalar;
            }
            return(newMat);
        }
Ejemplo n.º 4
0
        public override bool Equals(object obj)
        {
            if (!(obj is Matrix4f))
            {
                return(false);
            }

            Matrix4f m_obj = (Matrix4f)obj;

            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] != m_obj.values[i])
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 5
0
        public Matrix4f Multiply(Matrix4f other)
        {
            Matrix4f res = new Matrix4f();

            float _m00 = this.values[m00] * other.values[m00] + this.values[m10] * other.values[m01] + this.values[m20] * other.values[m02] + this.values[m30] * other.values[m03];
            float _m01 = this.values[m01] * other.values[m00] + this.values[m11] * other.values[m01] + this.values[m21] * other.values[m02] + this.values[m31] * other.values[m03];
            float _m02 = this.values[m02] * other.values[m00] + this.values[m12] * other.values[m01] + this.values[m22] * other.values[m02] + this.values[m32] * other.values[m03];
            float _m03 = this.values[m03] * other.values[m00] + this.values[m13] * other.values[m01] + this.values[m23] * other.values[m02] + this.values[m33] * other.values[m03];
            float _m10 = this.values[m00] * other.values[m10] + this.values[m10] * other.values[m11] + this.values[m20] * other.values[m12] + this.values[m30] * other.values[m13];
            float _m11 = this.values[m01] * other.values[m10] + this.values[m11] * other.values[m11] + this.values[m21] * other.values[m12] + this.values[m31] * other.values[m13];
            float _m12 = this.values[m02] * other.values[m10] + this.values[m12] * other.values[m11] + this.values[m22] * other.values[m12] + this.values[m32] * other.values[m13];
            float _m13 = this.values[m03] * other.values[m10] + this.values[m13] * other.values[m11] + this.values[m23] * other.values[m12] + this.values[m33] * other.values[m13];
            float _m20 = this.values[m00] * other.values[m20] + this.values[m10] * other.values[m21] + this.values[m20] * other.values[m22] + this.values[m30] * other.values[m23];
            float _m21 = this.values[m01] * other.values[m20] + this.values[m11] * other.values[m21] + this.values[m21] * other.values[m22] + this.values[m31] * other.values[m23];
            float _m22 = this.values[m02] * other.values[m20] + this.values[m12] * other.values[m21] + this.values[m22] * other.values[m22] + this.values[m32] * other.values[m23];
            float _m23 = this.values[m03] * other.values[m20] + this.values[m13] * other.values[m21] + this.values[m23] * other.values[m22] + this.values[m33] * other.values[m23];
            float _m30 = this.values[m00] * other.values[m30] + this.values[m10] * other.values[m31] + this.values[m20] * other.values[m32] + this.values[m30] * other.values[m33];
            float _m31 = this.values[m01] * other.values[m30] + this.values[m11] * other.values[m31] + this.values[m21] * other.values[m32] + this.values[m31] * other.values[m33];
            float _m32 = this.values[m02] * other.values[m30] + this.values[m12] * other.values[m31] + this.values[m22] * other.values[m32] + this.values[m32] * other.values[m33];
            float _m33 = this.values[m03] * other.values[m30] + this.values[m13] * other.values[m31] + this.values[m23] * other.values[m32] + this.values[m33] * other.values[m33];

            res.values[m00] = _m00;
            res.values[m01] = _m01;
            res.values[m02] = _m02;
            res.values[m03] = _m03;

            res.values[m10] = _m10;
            res.values[m11] = _m11;
            res.values[m12] = _m12;
            res.values[m13] = _m13;

            res.values[m20] = _m20;
            res.values[m21] = _m21;
            res.values[m22] = _m22;
            res.values[m23] = _m23;

            res.values[m30] = _m30;
            res.values[m31] = _m31;
            res.values[m32] = _m32;
            res.values[m33] = _m33;

            return(res);
        }
Ejemplo n.º 6
0
        public Matrix4f MultiplyStore(Matrix4f other)
        {
            float _m00 = this.values[m00] * other.values[m00] + this.values[m10] * other.values[m01] + this.values[m20] * other.values[m02] + this.values[m30] * other.values[m03];
            float _m01 = this.values[m01] * other.values[m00] + this.values[m11] * other.values[m01] + this.values[m21] * other.values[m02] + this.values[m31] * other.values[m03];
            float _m02 = this.values[m02] * other.values[m00] + this.values[m12] * other.values[m01] + this.values[m22] * other.values[m02] + this.values[m32] * other.values[m03];
            float _m03 = this.values[m03] * other.values[m00] + this.values[m13] * other.values[m01] + this.values[m23] * other.values[m02] + this.values[m33] * other.values[m03];
            float _m10 = this.values[m00] * other.values[m10] + this.values[m10] * other.values[m11] + this.values[m20] * other.values[m12] + this.values[m30] * other.values[m13];
            float _m11 = this.values[m01] * other.values[m10] + this.values[m11] * other.values[m11] + this.values[m21] * other.values[m12] + this.values[m31] * other.values[m13];
            float _m12 = this.values[m02] * other.values[m10] + this.values[m12] * other.values[m11] + this.values[m22] * other.values[m12] + this.values[m32] * other.values[m13];
            float _m13 = this.values[m03] * other.values[m10] + this.values[m13] * other.values[m11] + this.values[m23] * other.values[m12] + this.values[m33] * other.values[m13];
            float _m20 = this.values[m00] * other.values[m20] + this.values[m10] * other.values[m21] + this.values[m20] * other.values[m22] + this.values[m30] * other.values[m23];
            float _m21 = this.values[m01] * other.values[m20] + this.values[m11] * other.values[m21] + this.values[m21] * other.values[m22] + this.values[m31] * other.values[m23];
            float _m22 = this.values[m02] * other.values[m20] + this.values[m12] * other.values[m21] + this.values[m22] * other.values[m22] + this.values[m32] * other.values[m23];
            float _m23 = this.values[m03] * other.values[m20] + this.values[m13] * other.values[m21] + this.values[m23] * other.values[m22] + this.values[m33] * other.values[m23];
            float _m30 = this.values[m00] * other.values[m30] + this.values[m10] * other.values[m31] + this.values[m20] * other.values[m32] + this.values[m30] * other.values[m33];
            float _m31 = this.values[m01] * other.values[m30] + this.values[m11] * other.values[m31] + this.values[m21] * other.values[m32] + this.values[m31] * other.values[m33];
            float _m32 = this.values[m02] * other.values[m30] + this.values[m12] * other.values[m31] + this.values[m22] * other.values[m32] + this.values[m32] * other.values[m33];
            float _m33 = this.values[m03] * other.values[m30] + this.values[m13] * other.values[m31] + this.values[m23] * other.values[m32] + this.values[m33] * other.values[m33];

            this.values[m00] = _m00;
            this.values[m01] = _m01;
            this.values[m02] = _m02;
            this.values[m03] = _m03;

            this.values[m10] = _m10;
            this.values[m11] = _m11;
            this.values[m12] = _m12;
            this.values[m13] = _m13;

            this.values[m20] = _m20;
            this.values[m21] = _m21;
            this.values[m22] = _m22;
            this.values[m23] = _m23;

            this.values[m30] = _m30;
            this.values[m31] = _m31;
            this.values[m32] = _m32;
            this.values[m33] = _m33;

            return(this);
        }