/// <summary> /// /// </summary> /// <param name="col1"></param> /// <param name="col2"></param> /// <param name="col3"></param> public void Set(Double4 col1, Double4 col2, Double4 col3, Double4 col4) { this.col1 = col1; this.col2 = col2; this.col3 = col3; this.col4 = col4; }
/// <summary> /// /// </summary> /// <param name="col1"></param> /// <param name="col2"></param> public Matrix4x4(Double4 col1, Double4 col2, Double4 col3, Double4 col4) { this.col1 = col1; this.col2 = col2; this.col3 = col3; this.col4 = col4; }
/// <summary> /// * 运算 /// </summary> /// <param name="m1"></param> /// <param name="m2"></param> /// <returns></returns> public static Matrix4x4 operator *(Matrix4x4 m1, Matrix4x4 m2) { Double4 col1 = new Double4(Double4.Dot(m1.col1, m2.row1), Double4.Dot(m1.col1, m2.row2), Double4.Dot(m1.col1, m2.row3), Double4.Dot(m1.col1, m2.row4)); Double4 col2 = new Double4(Double4.Dot(m1.col2, m2.row1), Double4.Dot(m1.col2, m2.row2), Double4.Dot(m1.col2, m2.row3), Double4.Dot(m1.col2, m2.row4)); Double4 col3 = new Double4(Double4.Dot(m1.col3, m2.row1), Double4.Dot(m1.col3, m2.row2), Double4.Dot(m1.col3, m2.row3), Double4.Dot(m1.col3, m2.row4)); Double4 col4 = new Double4(Double4.Dot(m1.col4, m2.row1), Double4.Dot(m1.col4, m2.row2), Double4.Dot(m1.col4, m2.row3), Double4.Dot(m1.col4, m2.row4)); return(new Matrix4x4(col1, col2, col3, col4)); }
/// <summary> /// * 运算 /// </summary> /// <param name="k"></param> /// <param name="vector"></param> /// <returns></returns> public static Matrix4x4 operator *(Matrix4x4 v, double k) { Double4 m1 = v.col1 * k; Double4 m2 = v.col2 * k; Double4 m3 = v.col3 * k; Double4 m4 = v.col4 * k; return(new Matrix4x4(m1, m2, m3, m4)); }
/// <summary> /// 矩阵- /// </summary> /// <param name="v1"></param> /// <param name="v2"></param> /// <returns></returns> public static Matrix4x4 operator -(Matrix4x4 v1, Matrix4x4 v2) { Double4 m1 = v1.col1 - v2.col1; Double4 m2 = v1.col2 - v2.col2; Double4 m3 = v1.col3 - v2.col3; Double4 m4 = v1.col4 - v2.col4; return(new Matrix4x4(m1, m2, m3, m4)); }
public override bool Equals(System.Object obj) { if (obj == null) { return(false); } Double4 p = (Double4)obj; if ((System.Object)p == null) { return(false); } return((x == p.x) && (y == p.y) && (z == p.z) && (w == p.w)); }
/// <summary> /// * 运算 /// </summary> /// <param name="m1"></param> /// <param name="m2"></param> /// <returns></returns> public static Double4 operator *(Double4 v, Matrix4x4 m) { return(new Double4(Double4.Dot(v, m.row1), Double4.Dot(v, m.row2), Double4.Dot(v, m.row3), Double4.Dot(v, m.row4))); }
/// <summary> /// * 运算 /// </summary> /// <param name="m1"></param> /// <param name="m2"></param> /// <returns></returns> public static Double4 operator *(Matrix4x4 m, Double4 v) { return(new Double4(Double4.Dot(m.col1, v), Double4.Dot(m.col2, v), Double4.Dot(m.col3, v), Double4.Dot(m.col4, v))); }
/// <summary> /// 点积 /// </summary> /// <param name="a"></param> /// <param name="b"></param> /// <returns></returns> public static double Dot(Double4 a, Double4 b) //点积 { return(a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w); }