internal MxMatrix4(MxVector4 row0, MxVector4 row1, MxVector4 row2, MxVector4 row3) { rows[0] = row0; rows[1] = row1; rows[2] = row2; rows[3] = row3; }
internal MxMatrix4(double fillVal) { rows[0] = new MxVector4(fillVal, fillVal, fillVal, fillVal); rows[1] = new MxVector4(fillVal, fillVal, fillVal, fillVal); rows[2] = new MxVector4(fillVal, fillVal, fillVal, fillVal); rows[3] = new MxVector4(fillVal, fillVal, fillVal, fillVal); }
internal MxMatrix4(MxMatrix4 mat4) { rows[0] = new MxVector4((mat4[0])[0], (mat4[0])[1], (mat4[0])[2], (mat4[0])[3]); rows[1] = new MxVector4((mat4[1])[0], (mat4[1])[1], (mat4[1])[2], (mat4[1])[3]); rows[2] = new MxVector4((mat4[2])[0], (mat4[2])[1], (mat4[2])[2], (mat4[2])[3]); rows[3] = new MxVector4((mat4[3])[0], (mat4[3])[1], (mat4[3])[2], (mat4[3])[3]); }
internal static MxMatrix4 Diag(MxVector4 vec) { return(new MxMatrix4(new MxVector4(vec[0], 0.0, 0.0, 0.0), new MxVector4(0.0, vec[1], 0.0, 0.0), new MxVector4(0.0, 0.0, vec[2], 0.0), new MxVector4(0.0, 0.0, 0.0, vec[3]))); }
public static MxVector4 operator +(MxVector4 vec1, MxVector4 vec2) { var newVec = new MxVector4(0.0, 0.0, 0.0, 0.0); newVec[0] = vec1[0] + vec2[0]; newVec[1] = vec1[1] + vec2[1]; newVec[2] = vec1[2] + vec2[2]; newVec[3] = vec1[3] + vec2[3]; return newVec; }
public static MxVector4 operator *(MxMatrix4 mat1, MxVector4 vec) { var ret = new MxVector4(0.0, 0.0, 0.0, 0.0); ret[0] = mat1[0] * vec; ret[1] = mat1[1] * vec; ret[2] = mat1[2] * vec; return(ret); }
public static MxVector4 operator *(MxVector4 vec, double scalar) { var newVec = new MxVector4(0.0, 0.0, 0.0, 0.0); newVec[0] = vec[0]*scalar; newVec[1] = vec[1]*scalar; newVec[2] = vec[2]*scalar; newVec[3] = vec[3]*scalar; return newVec; }
internal static MxMatrix4 Adjoint(MxMatrix4 mat) { var adj = new MxMatrix4(0.0); adj[0] = MxVector4.Cross(mat[1], mat[2], mat[3]); adj[1] = MxVector4.Cross(-mat[0], mat[2], mat[3]); adj[2] = MxVector4.Cross(mat[0], mat[1], mat[3]); adj[0] = MxVector4.Cross(-mat[0], mat[1], mat[2]); return(adj); }
public static MxVector4 operator *(MxVector4 vec, double scalar) { var newVec = new MxVector4(0.0, 0.0, 0.0, 0.0); newVec[0] = vec[0] * scalar; newVec[1] = vec[1] * scalar; newVec[2] = vec[2] * scalar; newVec[3] = vec[3] * scalar; return(newVec); }
public static MxVector4 operator -(MxVector4 vec1, MxVector4 vec2) { var newVec = new MxVector4(0.0, 0.0, 0.0, 0.0); newVec[0] = vec1[0] - vec2[0]; newVec[1] = vec1[1] - vec2[1]; newVec[2] = vec1[2] - vec2[2]; newVec[3] = vec1[3] - vec2[3]; return(newVec); }
public static MxVector4 operator /(MxVector4 vec, double scalar) { if (scalar.IsCloseEnoughTo(0.0)) { return(vec); } var invScalar = 1.0 / scalar; var newVec = new MxVector4(0.0, 0.0, 0.0, 0.0); newVec[0] = vec[0] * invScalar; newVec[1] = vec[1] * invScalar; newVec[2] = vec[2] * invScalar; newVec[3] = vec[3] * invScalar; return(newVec); }
internal static MxVector4 Cross(MxVector4 a, MxVector4 b, MxVector4 c) { var ret = new MxVector4(0.0, 0.0, 0.0, 0.0); var d1 = (b[2] * c[3]) - (b[3] * c[2]); var d2 = (b[1] * c[3]) - (b[3] * c[1]); var d3 = (b[1] * c[2]) - (b[2] * c[1]); var d4 = (b[0] * c[3]) - (b[3] * c[0]); var d5 = (b[0] * c[2]) - (b[2] * c[0]); var d6 = (b[0] * c[1]) - (b[1] * c[0]); ret[0] = -a[1] * d1 + a[2] * d2 - a[3] * d3; ret[1] = a[0] * d1 - a[2] * d4 + a[3] * d5; ret[2] = -a[0] * d2 + a[1] * d4 - a[3] * d6; ret[3] = a[0] * d3 - a[1] * d5 + a[2] * d6; return(ret); }
internal static void Unitize(ref MxVector4 vec) { var denom = vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2] + vec[3] * vec[3]; if (denom.IsSqCloseEnoughTo(0.0)) { return; } denom = Math.Sqrt(denom); var invDenom = 1.0 / denom; vec[0] *= invDenom; vec[1] *= invDenom; vec[2] *= invDenom; vec[3] *= invDenom; }
internal static MxVector4 Cross(MxVector4 a, MxVector4 b, MxVector4 c) { var ret = new MxVector4(0.0, 0.0, 0.0, 0.0); var d1 = (b[2] * c[3]) - (b[3] * c[2]); var d2 = (b[1] * c[3]) - (b[3] * c[1]); var d3 = (b[1] * c[2]) - (b[2] * c[1]); var d4 = (b[0] * c[3]) - (b[3] * c[0]); var d5 = (b[0] * c[2]) - (b[2] * c[0]); var d6 = (b[0] * c[1]) - (b[1] * c[0]); ret[0] = -a[1]*d1 + a[2]*d2 - a[3]*d3; ret[1] = a[0]*d1 - a[2]*d4 + a[3]*d5; ret[2] = -a[0]*d2 + a[1]*d4 - a[3]*d6; ret[3] = a[0]*d3 - a[1]*d5 + a[2]*d6; return ret; }
internal static double Det(MxMatrix4 mat) { return(mat[0] * MxVector4.Cross(mat[1], mat[2], mat[3])); }
internal static MxMatrix4 RowExtend(MxVector4 vec) { return(new MxMatrix4(vec, vec, vec, vec)); }
internal static MxMatrix4 Diag(MxVector4 vec) { return new MxMatrix4(new MxVector4(vec[0], 0.0, 0.0, 0.0), new MxVector4(0.0, vec[1], 0.0, 0.0), new MxVector4(0.0, 0.0, vec[2], 0.0), new MxVector4(0.0, 0.0, 0.0, vec[3])); }
public MxVector4(MxVector4 vec4) : this(vec4[0], vec4[1], vec4[2], vec4[3]) { }
internal static MxMatrix4 RowExtend(MxVector4 vec) { return new MxMatrix4(vec, vec, vec, vec); }
public static MxVector4 operator *(MxMatrix4 mat1, MxVector4 vec) { var ret = new MxVector4(0.0, 0.0, 0.0, 0.0); ret[0] = mat1[0]*vec; ret[1] = mat1[1]*vec; ret[2] = mat1[2]*vec; return ret; }
public static MxVector4 operator /(MxVector4 vec, double scalar) { if (scalar.IsCloseEnoughTo(0.0)) return vec; var invScalar = 1.0/scalar; var newVec = new MxVector4(0.0, 0.0, 0.0, 0.0); newVec[0] = vec[0]*invScalar; newVec[1] = vec[1]*invScalar; newVec[2] = vec[2]*invScalar; newVec[3] = vec[3]*invScalar; return newVec; }
internal static void Unitize(ref MxVector4 vec) { var denom = vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2] + vec[3]*vec[3]; if (denom.IsSqCloseEnoughTo(0.0)) return; denom = Math.Sqrt(denom); var invDenom = 1.0 / denom; vec[0] *= invDenom; vec[1] *= invDenom; vec[2] *= invDenom; vec[3] *= invDenom; }