Ejemplo n.º 1
0
  public Matrix4x4 multiply(Matrix4x4 other) {
    if (this.flagBits == Mathematics.mat_type_Identity) return new Matrix4x4(other);
    else if (other.getType() == Mathematics.mat_type_Identity) return new Matrix4x4(this);

    return new Matrix4x4(
        // Fisrt Column
        mat4[0] * other.get_value(0)
            + mat4[4] * other.get_value(1)
            + mat4[8] * other.get_value(2)
            + mat4[12] * other.get_value(3),
        mat4[1] * other.get_value(0)
            + mat4[5] * other.get_value(1)
            + mat4[9] * other.get_value(2)
            + mat4[13] * other.get_value(3),
        mat4[2] * other.get_value(0)
            + mat4[6] * other.get_value(1)
            + mat4[10] * other.get_value(2)
            + mat4[14] * other.get_value(3),
        mat4[3] * other.get_value(0)
            + mat4[7] * other.get_value(1)
            + mat4[11] * other.get_value(2)
            + mat4[15] * other.get_value(3),

        // Second Column
        mat4[0] * other.get_value(4)
            + mat4[4] * other.get_value(5)
            + mat4[8] * other.get_value(6)
            + mat4[12] * other.get_value(7),
        mat4[1] * other.get_value(4)
            + mat4[5] * other.get_value(5)
            + mat4[9] * other.get_value(6)
            + mat4[13] * other.get_value(7),
        mat4[2] * other.get_value(4)
            + mat4[6] * other.get_value(5)
            + mat4[10] * other.get_value(6)
            + mat4[14] * other.get_value(7),
        mat4[3] * other.get_value(4)
            + mat4[7] * other.get_value(5)
            + mat4[11] * other.get_value(6)
            + mat4[15] * other.get_value(7),

        // Third Column
        mat4[0] * other.get_value(8)
            + mat4[4] * other.get_value(9)
            + mat4[8] * other.get_value(10)
            + mat4[12] * other.get_value(11),
        mat4[1] * other.get_value(8)
            + mat4[5] * other.get_value(9)
            + mat4[9] * other.get_value(10)
            + mat4[13] * other.get_value(11),
        mat4[2] * other.get_value(8)
            + mat4[6] * other.get_value(9)
            + mat4[10] * other.get_value(10)
            + mat4[14] * other.get_value(11),
        mat4[3] * other.get_value(8)
            + mat4[7] * other.get_value(9)
            + mat4[11] * other.get_value(10)
            + mat4[15] * other.get_value(11),

        // Fourth Column
        mat4[0] * other.get_value(12)
            + mat4[4] * other.get_value(13)
            + mat4[8] * other.get_value(14)
            + mat4[12] * other.get_value(15),
        mat4[1] * other.get_value(12)
            + mat4[5] * other.get_value(13)
            + mat4[9] * other.get_value(14)
            + mat4[13] * other.get_value(15),
        mat4[2] * other.get_value(12)
            + mat4[6] * other.get_value(13)
            + mat4[10] * other.get_value(14)
            + mat4[14] * other.get_value(15),
        mat4[3] * other.get_value(12)
            + mat4[7] * other.get_value(13)
            + mat4[11] * other.get_value(14)
            + mat4[15] * other.get_value(15)
        // is General matrix...
        );
  }