Ejemplo n.º 1
0
 public Mat4 Multiply(Mat4 matrix)
 {
     return new Mat4(new[,]
         {
             {
                 this[1, 1]*matrix[1, 1] + this[1, 2]*matrix[2, 1] + this[1, 3]*matrix[3, 1] +
                 this[1, 4]*matrix[4, 1],
                 this[1, 1]*matrix[1, 2] + this[1, 2]*matrix[2, 2] + this[1, 3]*matrix[3, 2] +
                 this[1, 4]*matrix[4, 2],
                 this[1, 1]*matrix[1, 3] + this[1, 2]*matrix[2, 3] + this[1, 3]*matrix[3, 3] +
                 this[1, 4]*matrix[4, 3],
                 this[1, 1]*matrix[1, 4] + this[1, 2]*matrix[2, 4] + this[1, 3]*matrix[3, 4] +
                 this[1, 4]*matrix[4, 4]
             },
             {
                 this[2, 1]*matrix[1, 1] + this[2, 2]*matrix[2, 1] + this[2, 3]*matrix[3, 1] +
                 this[2, 4]*matrix[4, 1],
                 this[2, 1]*matrix[1, 2] + this[2, 2]*matrix[2, 2] + this[2, 3]*matrix[3, 2] +
                 this[2, 4]*matrix[4, 2],
                 this[2, 1]*matrix[1, 3] + this[2, 2]*matrix[2, 3] + this[2, 3]*matrix[3, 3] +
                 this[2, 4]*matrix[4, 3],
                 this[2, 1]*matrix[1, 4] + this[2, 2]*matrix[2, 4] + this[2, 3]*matrix[3, 4] +
                 this[2, 4]*matrix[4, 4]
             },
             {
                 this[3, 1]*matrix[1, 1] + this[3, 2]*matrix[2, 1] + this[3, 3]*matrix[3, 1] +
                 this[3, 4]*matrix[4, 1],
                 this[3, 1]*matrix[1, 2] + this[3, 2]*matrix[2, 2] + this[3, 3]*matrix[3, 2] +
                 this[3, 4]*matrix[4, 2],
                 this[3, 1]*matrix[1, 3] + this[3, 2]*matrix[2, 3] + this[3, 3]*matrix[3, 3] +
                 this[3, 4]*matrix[4, 3],
                 this[3, 1]*matrix[1, 4] + this[3, 2]*matrix[2, 4] + this[3, 3]*matrix[3, 4] +
                 this[3, 4]*matrix[4, 4]
             },
             {
                 this[4, 1]*matrix[1, 1] + this[4, 2]*matrix[2, 1] + this[4, 3]*matrix[3, 1] +
                 this[4, 4]*matrix[4, 1],
                 this[4, 1]*matrix[1, 2] + this[4, 2]*matrix[2, 2] + this[4, 3]*matrix[3, 2] +
                 this[4, 4]*matrix[4, 2],
                 this[4, 1]*matrix[1, 3] + this[4, 2]*matrix[2, 3] + this[4, 3]*matrix[3, 3] +
                 this[4, 4]*matrix[4, 3],
                 this[4, 1]*matrix[1, 4] + this[4, 2]*matrix[2, 4] + this[4, 3]*matrix[3, 4] +
                 this[4, 4]*matrix[4, 4]
             }
         });
 }
Ejemplo n.º 2
0
 public Mat4 Subtract(Mat4 matrix)
 {
     return new Mat4(new[,]
         {
             {
                 this[1, 1] - matrix[1, 1], this[1, 2] - matrix[1, 2], this[1, 3] - matrix[1, 3],
                 this[1, 4] - matrix[1, 4]
             },
             {
                 this[2, 1] - matrix[2, 1], this[2, 2] - matrix[2, 2], this[2, 3] - matrix[2, 3],
                 this[2, 4] - matrix[2, 4]
             },
             {
                 this[3, 1] - matrix[3, 1], this[3, 2] - matrix[3, 2], this[3, 3] - matrix[3, 3],
                 this[3, 4] - matrix[3, 4]
             },
             {
                 this[4, 1] - matrix[4, 1], this[4, 2] - matrix[4, 2], this[4, 3] - matrix[4, 3],
                 this[4, 4] - matrix[4, 4]
             }
         });
 }
Ejemplo n.º 3
0
 public Mat4 Add(Mat4 matrix)
 {
     return new Mat4(new[,]
         {
             {
                 this[1, 1] + matrix[1, 1], this[1, 2] + matrix[1, 2], this[1, 3] + matrix[1, 3],
                 this[1, 4] + matrix[1, 4]
             },
             {
                 this[2, 1] + matrix[2, 1], this[2, 2] + matrix[2, 2], this[2, 3] + matrix[2, 3],
                 this[2, 4] + matrix[2, 4]
             },
             {
                 this[3, 1] + matrix[3, 1], this[3, 2] + matrix[3, 2], this[3, 3] + matrix[3, 3],
                 this[3, 4] + matrix[3, 4]
             },
             {
                 this[4, 1] + matrix[4, 1], this[4, 2] + matrix[4, 2], this[4, 3] + matrix[4, 3],
                 this[4, 4] + matrix[4, 4]
             }
         });
 }