public static bool Equals(Matrix3F matrix1, Matrix3F matrix2) { if (matrix1.IsDistinguishedIdentity || matrix2.IsDistinguishedIdentity) { return(matrix1.IsIdentity == matrix2.IsIdentity); } else { return(matrix1.M11.Equals(matrix2.M11) && matrix1.M12.Equals(matrix2.M12) && matrix1.M13.Equals(matrix2.M13) && matrix1.M14.Equals(matrix2.M14) && matrix1.M21.Equals(matrix2.M21) && matrix1.M22.Equals(matrix2.M22) && matrix1.M23.Equals(matrix2.M23) && matrix1.M24.Equals(matrix2.M24) && matrix1.M31.Equals(matrix2.M31) && matrix1.M32.Equals(matrix2.M32) && matrix1.M33.Equals(matrix2.M33) && matrix1.M34.Equals(matrix2.M34) && matrix1.OffsetX.Equals(matrix2.OffsetX) && matrix1.OffsetY.Equals(matrix2.OffsetY) && matrix1.OffsetZ.Equals(matrix2.OffsetZ) && matrix1.M44.Equals(matrix2.M44)); } }
private static Matrix3F CreateIdentity() { // Don't call this function, use s_identity. Matrix3F matrix = new Matrix3F(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); matrix.IsDistinguishedIdentity = true; return(matrix); }
public override bool Equals(object o) { if ((null == o) || !(o is Matrix3F)) { return(false); } Matrix3F value = (Matrix3F)o; return(Matrix3F.Equals(this, value)); }
public static Matrix3F operator *(Matrix3F matrix1, Matrix3F matrix2) { // Check if multiplying by identity. if (matrix1.IsDistinguishedIdentity) { return(matrix2); } if (matrix2.IsDistinguishedIdentity) { return(matrix1); } // Regular 4x4 matrix multiplication. Matrix3F result = new Matrix3F( matrix1._m11 * matrix2._m11 + matrix1._m12 * matrix2._m21 + matrix1._m13 * matrix2._m31 + matrix1._m14 * matrix2._offsetX, matrix1._m11 * matrix2._m12 + matrix1._m12 * matrix2._m22 + matrix1._m13 * matrix2._m32 + matrix1._m14 * matrix2._offsetY, matrix1._m11 * matrix2._m13 + matrix1._m12 * matrix2._m23 + matrix1._m13 * matrix2._m33 + matrix1._m14 * matrix2._offsetZ, matrix1._m11 * matrix2._m14 + matrix1._m12 * matrix2._m24 + matrix1._m13 * matrix2._m34 + matrix1._m14 * matrix2._m44, matrix1._m21 * matrix2._m11 + matrix1._m22 * matrix2._m21 + matrix1._m23 * matrix2._m31 + matrix1._m24 * matrix2._offsetX, matrix1._m21 * matrix2._m12 + matrix1._m22 * matrix2._m22 + matrix1._m23 * matrix2._m32 + matrix1._m24 * matrix2._offsetY, matrix1._m21 * matrix2._m13 + matrix1._m22 * matrix2._m23 + matrix1._m23 * matrix2._m33 + matrix1._m24 * matrix2._offsetZ, matrix1._m21 * matrix2._m14 + matrix1._m22 * matrix2._m24 + matrix1._m23 * matrix2._m34 + matrix1._m24 * matrix2._m44, matrix1._m31 * matrix2._m11 + matrix1._m32 * matrix2._m21 + matrix1._m33 * matrix2._m31 + matrix1._m34 * matrix2._offsetX, matrix1._m31 * matrix2._m12 + matrix1._m32 * matrix2._m22 + matrix1._m33 * matrix2._m32 + matrix1._m34 * matrix2._offsetY, matrix1._m31 * matrix2._m13 + matrix1._m32 * matrix2._m23 + matrix1._m33 * matrix2._m33 + matrix1._m34 * matrix2._offsetZ, matrix1._m31 * matrix2._m14 + matrix1._m32 * matrix2._m24 + matrix1._m33 * matrix2._m34 + matrix1._m34 * matrix2._m44, matrix1._offsetX * matrix2._m11 + matrix1._offsetY * matrix2._m21 + matrix1._offsetZ * matrix2._m31 + matrix1._m44 * matrix2._offsetX, matrix1._offsetX * matrix2._m12 + matrix1._offsetY * matrix2._m22 + matrix1._offsetZ * matrix2._m32 + matrix1._m44 * matrix2._offsetY, matrix1._offsetX * matrix2._m13 + matrix1._offsetY * matrix2._m23 + matrix1._offsetZ * matrix2._m33 + matrix1._m44 * matrix2._offsetZ, matrix1._offsetX * matrix2._m14 + matrix1._offsetY * matrix2._m24 + matrix1._offsetZ * matrix2._m34 + matrix1._m44 * matrix2._m44); return(result); }
internal static Matrix3F CreateRotationMatrix(ref QuaternionF quaternion, ref Point3F center) { Matrix3F matrix = s_identity; matrix.IsDistinguishedIdentity = false; // Will be using direct member access Float wx, wy, wz, xx, yy, yz, xy, xz, zz, x2, y2, z2; x2 = quaternion.X + quaternion.X; y2 = quaternion.Y + quaternion.Y; z2 = quaternion.Z + quaternion.Z; xx = quaternion.X * x2; xy = quaternion.X * y2; xz = quaternion.X * z2; yy = quaternion.Y * y2; yz = quaternion.Y * z2; zz = quaternion.Z * z2; wx = quaternion.W * x2; wy = quaternion.W * y2; wz = quaternion.W * z2; matrix._m11 = (Float)1.0 - (yy + zz); matrix._m12 = xy + wz; matrix._m13 = xz - wy; matrix._m21 = xy - wz; matrix._m22 = (Float)1.0 - (xx + zz); matrix._m23 = yz + wx; matrix._m31 = xz + wy; matrix._m32 = yz - wx; matrix._m33 = (Float)1.0 - (xx + yy); if (center.X != 0 || center.Y != 0 || center.Z != 0) { matrix._offsetX = -center.X * matrix._m11 - center.Y * matrix._m21 - center.Z * matrix._m31 + center.X; matrix._offsetY = -center.X * matrix._m12 - center.Y * matrix._m22 - center.Z * matrix._m32 + center.Y; matrix._offsetZ = -center.X * matrix._m13 - center.Y * matrix._m23 - center.Z * matrix._m33 + center.Z; } return(matrix); }
public static Vector3F Multiply(Vector3F vector, Matrix3F matrix) { return(matrix.Transform(vector)); }
public static Point4F Multiply(Point4F point, Matrix3F matrix) { return(matrix.Transform(point)); }
public void Append(Matrix3F matrix) { this *= matrix; }
public void Prepend(Matrix3F matrix) { this = matrix * this; }
public static Matrix3F Multiply(Matrix3F matrix1, Matrix3F matrix2) { return(matrix1 * matrix2); }
public bool Equals(Matrix3F value) { return(Matrix3F.Equals(this, value)); }