public static double3x3 transpose(double3x3 v) { return(double3x3( v.c0.x, v.c0.y, v.c0.z, v.c1.x, v.c1.y, v.c1.z, v.c2.x, v.c2.y, v.c2.z)); }
public static double3x3 quatToMatrix(quaternion_d q) { q = math.normalize(q); // Precalculate coordinate products double x = q.value.x * 2.0F; double y = q.value.y * 2.0F; double z = q.value.z * 2.0F; double xx = q.value.x * x; double yy = q.value.y * y; double zz = q.value.z * z; double xy = q.value.x * y; double xz = q.value.x * z; double yz = q.value.y * z; double wx = q.value.w * x; double wy = q.value.w * y; double wz = q.value.w * z; // Calculate 3x3 matrix from orthonormal basis var m = new double3x3 { m0 = new double3(1.0f - (yy + zz), xy + wz, xz - wy), m1 = new double3(xy - wz, 1.0f - (xx + zz), yz + wx), m2 = new double3(xz + wy, yz - wx, 1.0f - (xx + yy)) }; return(m); }
public static double3x3 inverse(double3x3 m) { // naive scalar implementation using direct calculation by cofactors double3 c0 = m.c0; double3 c1 = m.c1; double3 c2 = m.c2; // calculate minors double m00 = c1.y * c2.z - c1.z * c2.y; double m01 = c0.y * c2.z - c0.z * c2.y; double m02 = c0.y * c1.z - c0.z * c1.y; double m10 = c1.x * c2.z - c1.z * c2.x; double m11 = c0.x * c2.z - c0.z * c2.x; double m12 = c0.x * c1.z - c0.z * c1.x; double m20 = c1.x * c2.y - c1.y * c2.x; double m21 = c0.x * c2.y - c0.y * c2.x; double m22 = c0.x * c1.y - c0.y * c1.x; double det = c0.x * m00 - c1.x * m01 + c2.x * m02; return(double3x3( m00, -m10, m20, -m01, m11, -m21, m02, -m12, m22) * (1.0 / det)); }
public static double determinant(double3x3 m) { double3 c0 = m.c0; double3 c1 = m.c1; double3 c2 = m.c2; double m00 = c1.y * c2.z - c1.z * c2.y; double m01 = c0.y * c2.z - c0.z * c2.y; double m02 = c0.y * c1.z - c0.z * c1.y; return(c0.x * m00 - c1.x * m01 + c2.x * m02); }
/// <summary>Returns the double3x3 full inverse of a double3x3 matrix.</summary> public static double3x3 inverse(double3x3 m) { double3 c0 = m.c0; double3 c1 = m.c1; double3 c2 = m.c2; double3 t0 = double3(c1.x, c2.x, c0.x); double3 t1 = double3(c1.y, c2.y, c0.y); double3 t2 = double3(c1.z, c2.z, c0.z); double3 m0 = t1 * t2.yzx - t1.yzx * t2; double3 m1 = t0.yzx * t2 - t0 * t2.yzx; double3 m2 = t0 * t1.yzx - t0.yzx * t1; double rcpDet = 1.0 / csum(t0.zxy * m0); return(double3x3(m0, m1, m2) * rcpDet); }
public static float3x3 float3x3(double3x3 v) { return(new float3x3(v)); }
public float3x3(double3x3 v) { this.c0 = (float3)v.c0; this.c1 = (float3)v.c1; this.c2 = (float3)v.c2; }
public int3x3(double3x3 v) { this.c0 = (int3)v.c0; this.c1 = (int3)v.c1; this.c2 = (int3)v.c2; }
public static int3x3 int3x3(double3x3 v) { return(new int3x3(v)); }
public static uint3 hash_wide(double3x3 v) { return((fold_to_uint(v.c0) * uint3(0xB8B208C7u, 0x5D3ED947u, 0x4473BBB1u) + fold_to_uint(v.c1) * uint3(0xCBA11D5Fu, 0x685835CFu, 0xC3D32AE1u) + fold_to_uint(v.c2) * uint3(0xB966942Fu, 0xFE9856B3u, 0xFA3A3285u)) + 0xAD55999Du); }
public static uint hash(double3x3 v) { return(csum(fold_to_uint(v.c0) * uint3(0xFAAF07DDu, 0x625C45BDu, 0xC9F27FCBu) + fold_to_uint(v.c1) * uint3(0x6D2523B1u, 0x6E2BF6A9u, 0xCC74B3B7u) + fold_to_uint(v.c2) * uint3(0x83B58237u, 0x833E3E29u, 0xA9D919BFu)) + 0xC3EC1D97u); }
public static uint hash(double3x3 v) { return(csum(fold_to_uint(v.c0) * uint3(0xF18EEB85u, 0x9E19BFC3u, 0x8196B06Fu) + fold_to_uint(v.c1) * uint3(0xD24EFA19u, 0x7D8048BBu, 0x713BD06Fu) + fold_to_uint(v.c2) * uint3(0x753AD6ADu, 0xD19764C7u, 0xB5D0BF63u)) + 0xF9102C5Fu); }
public static uint3 hashwide(double3x3 v) { return((fold_to_uint(v.c0) * uint3(0x91475DF7u, 0x55E84827u, 0x90A285BBu) + fold_to_uint(v.c1) * uint3(0x5D19E1D5u, 0xFAAF07DDu, 0x625C45BDu) + fold_to_uint(v.c2) * uint3(0xC9F27FCBu, 0x6D2523B1u, 0x6E2BF6A9u)) + 0xCC74B3B7u); }
public static uint hash(double3x3 v) { return(csum(fold_to_uint(v.c0) * uint3(0xAC5DB57Bu, 0xA91A02EDu, 0xB3C49313u) + fold_to_uint(v.c1) * uint3(0xF43A9ABBu, 0x84E7E01Bu, 0x8E055BE5u) + fold_to_uint(v.c2) * uint3(0x6E624EB7u, 0x7383ED49u, 0xDD49C23Bu)) + 0xEBD0D005u); }
public static uint3x3 uint3x3(double3x3 v) { return(new uint3x3(v)); }
public static uint3 hashwide(double3x3 v) { return((fold_to_uint(v.c0) * uint3(0x9C9F0823u, 0x5A9CA13Bu, 0xAFCDD5EFu) + fold_to_uint(v.c1) * uint3(0xA88D187Du, 0xCF6EBA1Du, 0x9D88E5A1u) + fold_to_uint(v.c2) * uint3(0xEADF0775u, 0x747A9D7Bu, 0x4111F799u)) + 0xB5F05AF1u); }
public static uint hash(double3x3 v) { return(csum(fold_to_uint(v.c0) * uint3(0xB36DE767u, 0x6FCA387Du, 0xAF0F3103u) + fold_to_uint(v.c1) * uint3(0xE4A056C7u, 0x841D8225u, 0xC9393C7Du) + fold_to_uint(v.c2) * uint3(0xD42EAFA3u, 0xD9AFD06Du, 0x97A65421u)) + 0x7809205Fu); }