/// <summary>Constructs a float3x3 matrix from a unit quaternion.</summary> public float3x3(quaternion q) { float4 v = q.value; float4 v2 = v + v; uint3 npn = uint3(0x80000000, 0x00000000, 0x80000000); uint3 nnp = uint3(0x80000000, 0x80000000, 0x00000000); uint3 pnn = uint3(0x00000000, 0x80000000, 0x80000000); c0 = v2.y * asfloat(asuint(v.yxw) ^ npn) - v2.z * asfloat(asuint(v.zwx) ^ pnn) + float3(1, 0, 0); c1 = v2.z * asfloat(asuint(v.wzy) ^ nnp) - v2.x * asfloat(asuint(v.yxw) ^ npn) + float3(0, 1, 0); c2 = v2.x * asfloat(asuint(v.zwx) ^ pnn) - v2.y * asfloat(asuint(v.wzy) ^ nnp) + float3(0, 0, 1); /* * // TODO: This should be better, but it isn't currently because the input quaternion ends being loaded as scalars for some reason. * // Test again later. * float4 xv2 = v.x * v2; * float4 yv2 = v.y * v2; * float4 zv2 = v.z * v2; * float4 wv2 = v.w * v2; * uint3 npn = uint3(0x80000000, 0x00000000, 0x80000000); * uint3 nnp = uint3(0x80000000, 0x80000000, 0x00000000); * uint3 pnn = uint3(0x00000000, 0x80000000, 0x80000000); * c0 = asfloat(asuint(yv2.yxw) ^ npn) - asfloat(asuint(zv2.zwx) ^ pnn) + float3(1, 0, 0); * c1 = asfloat(asuint(zv2.wzy) ^ nnp) - asfloat(asuint(xv2.yxw) ^ npn) + float3(0, 1, 0); * c2 = asfloat(asuint(xv2.zwx) ^ pnn) - asfloat(asuint(yv2.wzy) ^ nnp) + float3(0, 0, 1); */ /* * // handles scale * float dt = dot(v,v); * uint3 npn = uint3(0x80000000, 0x00000000, 0x80000000); * uint3 nnp = uint3(0x80000000, 0x80000000, 0x00000000); * uint3 pnn = uint3(0x00000000, 0x80000000, 0x80000000); * c0 = v2.y * asfloat(asuint(v.yxw) ^ npn) - v2.z * asfloat(asuint(v.zwx) ^ pnn); * c1 = v2.z * asfloat(asuint(v.wzy) ^ nnp) - v2.x * asfloat(asuint(v.yxw) ^ npn); * c2 = v2.x * asfloat(asuint(v.zwx) ^ pnn) - v2.y * asfloat(asuint(v.wzy) ^ nnp); */ }
public uint3x3(double3x3 v) { this.c0 = (uint3)v.c0; this.c1 = (uint3)v.c1; this.c2 = (uint3)v.c2; }
public int3(uint3 v) { this.x = (int)v.x; this.y = (int)v.y; this.z = (int)v.z; }
public uint3x2(double v) { this.c0 = (uint3)v; this.c1 = (uint3)v; }
public uint3x2(float v) { this.c0 = (uint3)v; this.c1 = (uint3)v; }
public static uint3x2 uint3x2(uint3 c0, uint3 c1) { return(new uint3x2(c0, c1)); }
public uint3x2(uint v) { this.c0 = v; this.c1 = v; }
public uint3x2(double3x2 v) { this.c0 = (uint3)v.c0; this.c1 = (uint3)v.c1; }
public uint3x3(uint v) { this.c0 = v; this.c1 = v; this.c2 = v; }
public uint3x3(uint3 c0, uint3 c1, uint3 c2) { this.c0 = c0; this.c1 = c1; this.c2 = c2; }
public static uint3x4 uint3x4(uint3 c0, uint3 c1, uint3 c2, uint3 c3) { return(new uint3x4(c0, c1, c2, c3)); }
public static uint hash(uint3 v) { return(csum(v * uint3(0x91D13847u, 0x52F7230Fu, 0xCF286E83u)) + 0xE121E6ADu); }
public DebuggerProxy(uint3 v) { x = v.x; y = v.y; z = v.z; }
public static uint hash(uint3 v) { return(csum(v * uint3(0x7BE39F3Bu, 0xFAB9913Fu, 0xB4501269u)) + 0xE04B89FDu); }
public uint3x3(bool v) { this.c0 = math.select(new uint3(0u), new uint3(1u), v); this.c1 = math.select(new uint3(0u), new uint3(1u), v); this.c2 = math.select(new uint3(0u), new uint3(1u), v); }
public uint3x3(int v) { this.c0 = (uint3)v; this.c1 = (uint3)v; this.c2 = (uint3)v; }
public DebuggerProxy(uint3 vec) { x = vec.x; y = vec.y; z = vec.z; }
public static uint3x3 uint3x3(uint3 c0, uint3 c1, uint3 c2) { return(new uint3x3(c0, c1, c2)); }
public uint3x2(uint3 c0, uint3 c1) { this.c0 = c0; this.c1 = c1; }
public uint3x3(float3x3 v) { this.c0 = (uint3)v.c0; this.c1 = (uint3)v.c1; this.c2 = (uint3)v.c2; }
public uint3x2(bool3x2 v) { this.c0 = math.select(new uint3(0u), new uint3(1u), v.c0); this.c1 = math.select(new uint3(0u), new uint3(1u), v.c1); }
public uint3 NextUInt3(uint3 max) { return(uint3((uint)(NextState() * (ulong)max.x >> 32), (uint)(NextState() * (ulong)max.y >> 32), (uint)(NextState() * (ulong)max.z >> 32))); }
public uint3x2(int v) { this.c0 = (uint3)v; this.c1 = (uint3)v; }
public static uint csum(uint3 a) { return(a.x + a.y + a.z); }
public uint3x2(float3x2 v) { this.c0 = (uint3)v.c0; this.c1 = (uint3)v.c1; }
public static float3 float3(uint3 v) { return(new float3(v)); }
public static int3 int3(uint3 v) { return(new int3(v)); }
public float3(uint3 v) { this.x = v.x; this.y = v.y; this.z = v.z; }
public static uint3 uint3(uint3 xyz) { return(new uint3(xyz)); }
public double3(uint3 v) { this.x = v.x; this.y = v.y; this.z = v.z; }