private void Start() { transform.position = UnityEngine.Vector3.zero; //take vertices and organize them into clockwise triangles to be passed to triangle intersection function Unity.Mathematics.float3 a = tetrahderonVertices[0]; Unity.Mathematics.float3 b = tetrahderonVertices[1]; Unity.Mathematics.float3 c = tetrahderonVertices[2]; Unity.Mathematics.float3 d = tetrahderonVertices[3]; Unity.Mathematics.float3x3 triangle1 = new Unity.Mathematics.float3x3(a, b, c); Unity.Mathematics.float3x3 triangle2 = new Unity.Mathematics.float3x3(a, c, d); Unity.Mathematics.float3x3 triangle3 = new Unity.Mathematics.float3x3(a, d, b); Unity.Mathematics.float3x3 triangle4 = new Unity.Mathematics.float3x3(b, c, d); triXC = new System.Collections.Generic.List <TriangleCrossSection>(); BuildTriangle(triangle1, planePos, planeNormal); BuildTriangle(triangle2, planePos, planeNormal); BuildTriangle(triangle3, planePos, planeNormal); BuildTriangle(triangle4, planePos, planeNormal); gameObject.AddComponent <UnityEngine.MeshRenderer>(); gameObject.AddComponent <UnityEngine.MeshFilter>(); gameObject.GetComponent <MeshRenderer>().material = mat; }
private void BuildTriangle(Unity.Mathematics.float3x3 vertices, Unity.Mathematics.float3 planePos, Unity.Mathematics.float3 planeNorm) { UnityEngine.GameObject tri1_go = new UnityEngine.GameObject(); tri1_go.transform.parent = this.transform; tri1_go.AddComponent <TriangleCrossSection>(); triXC.Add(tri1_go.GetComponent <TriangleCrossSection>()); tri1_go.GetComponent <TriangleCrossSection>().triangleVerticies = vertices; tri1_go.GetComponent <TriangleCrossSection>().planePos = planePos; tri1_go.GetComponent <TriangleCrossSection>().planeNormal = planeNorm; tri1_go.GetComponent <TriangleCrossSection>().mat = mat; }
private void UpdateTriangles() { //take vertices and organize them into clockwise triangles to be passed to triangle intersection function Unity.Mathematics.float3 a = tetrahderonVertices[0]; Unity.Mathematics.float3 b = tetrahderonVertices[1]; Unity.Mathematics.float3 c = tetrahderonVertices[2]; Unity.Mathematics.float3 d = tetrahderonVertices[3]; Unity.Mathematics.float3x3 triangle1 = new Unity.Mathematics.float3x3(a, b, c); Unity.Mathematics.float3x3 triangle2 = new Unity.Mathematics.float3x3(a, c, d); Unity.Mathematics.float3x3 triangle3 = new Unity.Mathematics.float3x3(a, d, b); Unity.Mathematics.float3x3 triangle4 = new Unity.Mathematics.float3x3(b, c, d); triXC.ForEach(p => p.planePos = planePos); triXC.ForEach(p => p.planeNormal = planeNormal); triXC[0].triangleVerticies = triangle1; triXC[1].triangleVerticies = triangle2; triXC[2].triangleVerticies = triangle3; triXC[3].triangleVerticies = triangle4; }
public double3x3(float3x3 v) { this.c0 = v.c0; this.c1 = v.c1; this.c2 = v.c2; }
public static int3x3 int3x3(float3x3 v) { return(new int3x3(v)); }
public static uint3 hashwide(float3x3 v) { return((asuint(v.c0) * uint3(0xCD0445A5u, 0xD2B90D9Bu, 0xD35C9B2Du) + asuint(v.c1) * uint3(0xA10D9E27u, 0x568DAAA9u, 0x7530254Fu) + asuint(v.c2) * uint3(0x9F090439u, 0x5E9F85C9u, 0x8C4CA03Fu)) + 0xB8D969EDu); }
/// <summary>Returns a float4x4 constructed from a float3x3 rotation matrix and a float3 translation vector.</summary> public static float4x4 float4x4(float3x3 rotation, float3 translation) { return(new float4x4(rotation, translation)); }
public static RigidTransform RigidTransform(float3x3 rotation, float3 translation) { return(new RigidTransform(rotation, translation)); }
public AffineTransform(float3x4 m) { rs = math.float3x3(m.c0, m.c1, m.c2); t = m.c3; }
public static uint3x3 uint3x3(float3x3 v) { return(new uint3x3(v)); }
public static float3x3 transpose(float3x3 m) { return(float3x3(m.c0.x, m.c0.y, m.c0.z, m.c1.x, m.c1.y, m.c1.z, m.c2.x, m.c2.y, m.c2.z)); }
public static float3x3 mul(float3x3 a, float3x3 b) { return(float3x3(mul(a, b.c0), mul(a, b.c1), mul(a, b.c2))); }
public static float3 mul(float3x3 x, float3 v) { return(mad(x.c2, v.z, mad(x.c0, v.x, x.c1 * v.y))); }
public static uint hash(float3x3 v) { return(csum(asuint(v.c0) * uint3(0x4473BBB1u, 0xCBA11D5Fu, 0x685835CFu) + asuint(v.c1) * uint3(0xC3D32AE1u, 0xB966942Fu, 0xFE9856B3u) + asuint(v.c2) * uint3(0xFA3A3285u, 0xAD55999Du, 0xDCDD5341u)) + 0x94DDD769u); }
public static uint3 hash_wide(float3x3 v) { return((asuint(v.c0) * uint3(0x84E7E01Bu, 0x8E055BE5u, 0x6E624EB7u) + asuint(v.c1) * uint3(0x7383ED49u, 0xDD49C23Bu, 0xEBD0D005u) + asuint(v.c2) * uint3(0x91475DF7u, 0x55E84827u, 0x90A285BBu)) + 0x5D19E1D5u); }
public AffineTransform(float3x3 rotationScale) { rs = rotationScale; t = float3.zero; }
public AffineTransform(RigidTransform rigid) { rs = math.float3x3(rigid.rot); t = rigid.pos; }
public static quaternion quaternion(float3x3 m) { return(new quaternion(m)); }
public AffineTransform(float4x4 m) { rs = math.float3x3(m.c0.xyz, m.c1.xyz, m.c2.xyz); t = m.c3.xyz; }
public static AffineTransform AffineTransform(float3x3 rotationScale) { return(new AffineTransform(rotationScale)); }
public RigidTransform(float3x3 rotation, float3 translation) { this.rot = new quaternion(rotation); this.pos = translation; }
public static AffineTransform mul(float3x3 a, AffineTransform b) { return(new AffineTransform(mul(a, b.t), mul(a, b.rs))); }
public static uint hash(float3x3 v) { return(csum(asuint(v.c0) * uint3(0x713BD06Fu, 0x753AD6ADu, 0xD19764C7u) + asuint(v.c1) * uint3(0xB5D0BF63u, 0xF9102C5Fu, 0x9881FB9Fu) + asuint(v.c2) * uint3(0x56A1530Du, 0x804B722Du, 0x738E50E5u)) + 0x4FC93C25u); }
public static AffineTransform mul(AffineTransform a, float3x3 b) { return(new AffineTransform(a.t, mul(b, a.rs))); }
public int3x3(float3x3 v) { this.c0 = (int3)v.c0; this.c1 = (int3)v.c1; this.c2 = (int3)v.c2; }
public AffineTransform(float3 translation, quaternion rotation) { rs = float3x3(rotation); t = translation; }
public static uint hash(float3x3 v) { return(csum(asuint(v.c0) * uint3(0x6985C229u, 0xE133B0B3u, 0xC3E0A3B9u) + asuint(v.c1) * uint3(0xFE31134Fu, 0x712A34D7u, 0x9D77A59Bu) + asuint(v.c2) * uint3(0x4942CA39u, 0xB40EC62Du, 0x565ED63Fu)) + 0x93C30C2Bu); }
public AffineTransform(float3 translation, quaternion rotation, float3 scale) { rs = mulScale(math.float3x3(rotation), scale); t = translation; }
public static double3x3 double3x3(float3x3 v) { return(new double3x3(v)); }
public AffineTransform(float3 translation, float3x3 rotationScale) { rs = rotationScale; t = translation; }