Exemple #1
0
 public static uint3 hash_wide(float3x4 v)
 {
     return((asuint(v.c0) * uint3(0x9C8A2F05u, 0x4DDC6509u, 0x7CF083CBu) +
             asuint(v.c1) * uint3(0x5C4D6CEDu, 0xF9137117u, 0xE857DCE1u) +
             asuint(v.c2) * uint3(0xF62213C5u, 0x9CDAA959u, 0xAA269ABFu) +
             asuint(v.c3) * uint3(0xD54BA36Fu, 0xFD0847B9u, 0x8189A683u)) + 0xB139D651u);
 }
 public int3x4(float3x4 v)
 {
     this.c0 = (int3)v.c0;
     this.c1 = (int3)v.c1;
     this.c2 = (int3)v.c2;
     this.c3 = (int3)v.c3;
 }
Exemple #3
0
 public static uint hash(float3x4 v)
 {
     return(csum(asuint(v.c0) * uint3(0x7AA2C2BDu, 0xE16BC89Du, 0x7AA07CD3u) +
                 asuint(v.c1) * uint3(0xAF642BA9u, 0xA8F2213Bu, 0x9F3FDC37u) +
                 asuint(v.c2) * uint3(0xAC60D0C3u, 0x9263662Fu, 0xE69626FFu) +
                 asuint(v.c3) * uint3(0xBD010EEBu, 0x9CEDE1D1u, 0x43BE0B51u)) + 0xAF836EE1u);
 }
Exemple #4
0
 public static uint hash(float3x4 v)
 {
     return(csum(asuint(v.c0) * uint3(0x69B60C81u, 0xE0EB6C25u, 0xF648BEABu) +
                 asuint(v.c1) * uint3(0x6BDB2B07u, 0xEF63C699u, 0x9001903Fu) +
                 asuint(v.c2) * uint3(0xA895B9CDu, 0x9D23B201u, 0x4B01D3E1u) +
                 asuint(v.c3) * uint3(0x7461CA0Du, 0x79725379u, 0xD6258E5Bu)) + 0xEE390C97u);
 }
Exemple #5
0
 public static uint hash(float3x4 v)
 {
     return(csum(asuint(v.c0) * uint3(0xB36DE767u, 0x6FCA387Du, 0xAF0F3103u) +
                 asuint(v.c1) * uint3(0xE4A056C7u, 0x841D8225u, 0xC9393C7Du) +
                 asuint(v.c2) * uint3(0xD42EAFA3u, 0xD9AFD06Du, 0x97A65421u) +
                 asuint(v.c3) * uint3(0x7809205Fu, 0x9C9F0823u, 0x5A9CA13Bu)) + 0xAFCDD5EFu);
 }
Exemple #6
0
 public static uint3 hashwide(float3x4 v)
 {
     return((asuint(v.c0) * uint3(0xB130C137u, 0x54834775u, 0x7C022221u) +
             asuint(v.c1) * uint3(0xA2D00EDFu, 0xA8977779u, 0x9F1C739Bu) +
             asuint(v.c2) * uint3(0x4B1BD187u, 0x9DF50593u, 0xF18EEB85u) +
             asuint(v.c3) * uint3(0x9E19BFC3u, 0x8196B06Fu, 0xD24EFA19u)) + 0x7D8048BBu);
 }
 public static uint hash(float3x4 v)
 {
     return(csum(asuint(v.c0) * uint3(0xF9EA92D5u, 0xC2FAFCB9u, 0x616E9CA1u) +
                 asuint(v.c1) * uint3(0xC5C5394Bu, 0xCAE78587u, 0x7A1541C9u) +
                 asuint(v.c2) * uint3(0xF83BD927u, 0x6A243BCBu, 0x509B84C9u) +
                 asuint(v.c3) * uint3(0x91D13847u, 0x52F7230Fu, 0xCF286E83u)) + 0xE121E6ADu);
 }
 public double3x4(float3x4 v)
 {
     this.c0 = v.c0;
     this.c1 = v.c1;
     this.c2 = v.c2;
     this.c3 = v.c3;
 }
Exemple #9
0
 public fix64p3x4(float3x4 v)
 {
     this.c0 = (fix64p3)v.c0;
     this.c1 = (fix64p3)v.c1;
     this.c2 = (fix64p3)v.c2;
     this.c3 = (fix64p3)v.c3;
 }
Exemple #10
0
 public static float4x3 transpose(float3x4 v)
 {
     return(float4x3(
                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,
                v.c3.x, v.c3.y, v.c3.z));
 }
        /// <summary>Fast matrix inverse for rigid transforms (orthonormal basis and translation)</summary>
        /// <param name="m">Matrix to invert.</param>
        /// <returns>The inverted matrix.</returns>
        public static float3x4 fastinverse(float3x4 m)
        {
            float3 c0  = m.c0;
            float3 c1  = m.c1;
            float3 c2  = m.c2;
            float3 pos = m.c3;

            float3 r0 = float3(c0.x, c1.x, c2.x);
            float3 r1 = float3(c0.y, c1.y, c2.y);
            float3 r2 = float3(c0.z, c1.z, c2.z);

            pos = -(r0 * pos.x + r1 * pos.y + r2 * pos.z);

            return(float3x4(r0, r1, r2, pos));
        }
 public static int3x4 int3x4(float3x4 v)
 {
     return(new int3x4(v));
 }
Exemple #13
0
 public static fix64p3x4 fix64p3x4(float3x4 v)
 {
     return(new fix64p3x4(v));
 }
Exemple #14
0
 public static uint3x4 uint3x4(float3x4 v)
 {
     return(new uint3x4(v));
 }
 public AffineTransform(float3x4 m)
 {
     rs = math.float3x3(m.c0, m.c1, m.c2);
     t  = m.c3;
 }
 public static AffineTransform AffineTransform(float3x4 m)
 {
     return(new AffineTransform(m));
 }
 public static double3x4 double3x4(float3x4 v)
 {
     return(new double3x4(v));
 }
Exemple #18
0
        public void crossSectTetrahedron(Unity.Mathematics.float3 point, Unity.Mathematics.float3 normalDirection,
                                         Unity.Mathematics.float3x4 vertices, UnityEngine.Mesh tetrahedronMesh)
        {
            //take vertices and organize them into clockwise triangles to be passed to triangle intersection function
            Unity.Mathematics.float3 a = vertices.c0;
            Unity.Mathematics.float3 b = vertices.c1;
            Unity.Mathematics.float3 c = vertices.c2;
            Unity.Mathematics.float3 d = vertices.c3;

            Unity.Mathematics.float3[] triangle1 = { a, b, c };
            Unity.Mathematics.float3[] triangle2 = { a, c, d };
            Unity.Mathematics.float3[] triangle3 = { a, d, b };
            Unity.Mathematics.float3[] triangle4 = { b, c, d };

            Unity.Mathematics.float3 triangle1point = a;
            Unity.Mathematics.float3 triangle2point = a;
            Unity.Mathematics.float3 triangle3point = a;
            Unity.Mathematics.float3 triangle4point = b;

            Unity.Mathematics.float3 triangle1Normal =
                Unity.Mathematics.math.cross(UnityEngine.Vector3.Normalize(c - a),
                                             UnityEngine.Vector3.Normalize(b - a));
            Unity.Mathematics.float3 triangle2Normal =
                Unity.Mathematics.math.cross(UnityEngine.Vector3.Normalize(c - a),
                                             UnityEngine.Vector3.Normalize(d - a));
            Unity.Mathematics.float3 triangle3Normal =
                Unity.Mathematics.math.cross(UnityEngine.Vector3.Normalize(d - a),
                                             UnityEngine.Vector3.Normalize(b - a));
            Unity.Mathematics.float3 triangle4Normal =
                Unity.Mathematics.math.cross(UnityEngine.Vector3.Normalize(c - b),
                                             UnityEngine.Vector3.Normalize(d - b));

            //TODO make this pretty
            UnityEngine.LineRenderer crossSectionRenderer1 = triXC[0].GetComponent <UnityEngine.LineRenderer>();
            UnityEngine.LineRenderer crossSectionRenderer2 = triXC[1].GetComponent <UnityEngine.LineRenderer>();
            UnityEngine.LineRenderer crossSectionRenderer3 = triXC[2].GetComponent <UnityEngine.LineRenderer>();
            UnityEngine.LineRenderer crossSectionRenderer4 = triXC[3].GetComponent <UnityEngine.LineRenderer>();

            int vertCount = 0;

            bool line1 = false, line2 = false, line3 = false, line4 = false;

            if (crossSectionRenderer1.enabled)
            {
                vertCount++;
                line1 = true;
            }

            if (crossSectionRenderer2.enabled)
            {
                vertCount++;
                line2 = true;
            }

            if (crossSectionRenderer3.enabled)
            {
                vertCount++;
                line3 = true;
            }

            if (crossSectionRenderer4.enabled)
            {
                vertCount++;
                line4 = true;
            }

            //Intersection is Triangle
            if (vertCount == 3)
            {
                //verts
                UnityEngine.Vector3[] verts = new UnityEngine.Vector3[3];

                if (line1 && line2 && line3)
                {
                    //a way to avoid checking orientation of line segments
                    verts[0] = crossSectionRenderer1.GetPosition(0);
                    verts[1] = crossSectionRenderer1.GetPosition(1);
                    verts[2] =
                        crossSectionRenderer2.GetPosition(1) == verts[0] ||
                        crossSectionRenderer2.GetPosition(1) == verts[1]
                            ? crossSectionRenderer2.GetPosition(0)
                            : crossSectionRenderer2.GetPosition(1);
                }

                else if (line1 && line2 && line4)
                {
                    verts[0] = crossSectionRenderer1.GetPosition(0);
                    verts[1] = crossSectionRenderer1.GetPosition(1);
                    verts[2] =
                        crossSectionRenderer2.GetPosition(1) == verts[0] ||
                        crossSectionRenderer2.GetPosition(1) == verts[1]
                            ? crossSectionRenderer2.GetPosition(0)
                            : crossSectionRenderer2.GetPosition(1);
                }

                else if (line1 && line3 && line4)
                {
                    verts[0] = crossSectionRenderer1.GetPosition(0);
                    verts[1] = crossSectionRenderer1.GetPosition(1);
                    verts[2] =
                        crossSectionRenderer3.GetPosition(1) == verts[0] ||
                        crossSectionRenderer3.GetPosition(1) == verts[1]
                            ? crossSectionRenderer3.GetPosition(0)
                            : crossSectionRenderer3.GetPosition(1);
                }

                else if (line2 && line3 && line4)
                {
                    verts[0] = crossSectionRenderer2.GetPosition(0);
                    verts[1] = crossSectionRenderer2.GetPosition(1);
                    verts[2] =
                        crossSectionRenderer3.GetPosition(1) == verts[0] ||
                        crossSectionRenderer3.GetPosition(1) == verts[1]
                            ? crossSectionRenderer3.GetPosition(0)
                            : crossSectionRenderer3.GetPosition(1);
                }
                tetrahedronMesh.vertices = verts;

                //tris
                int[] tris = { 0, 1, 2 };
                tetrahedronMesh.triangles = tris;
            }
            //Intersection is quadrilateral
            else if (vertCount == 4)
            {
                //verts
                UnityEngine.Vector3[] verts = new UnityEngine.Vector3[4];

                verts[0] = crossSectionRenderer2.GetPosition(0);
                verts[1] = crossSectionRenderer2.GetPosition(1);
                verts[2] =
                    (crossSectionRenderer3.GetPosition(1) == verts[0] ||
                     crossSectionRenderer3.GetPosition(1) == verts[1])
                        ? crossSectionRenderer3.GetPosition(0)
                        : crossSectionRenderer3.GetPosition(1);
                verts[3] =
                    (crossSectionRenderer4.GetPosition(1) == verts[0] ||
                     crossSectionRenderer4.GetPosition(1) == verts[1] ||
                     crossSectionRenderer4.GetPosition(1) == verts[2])
                        ? crossSectionRenderer4.GetPosition(0)
                        : crossSectionRenderer4.GetPosition(1);

                tetrahedronMesh.vertices = verts;

                //tris
                //find the opposite corner to #0
                //assume 0,1,2,3
                float3 cross0 = IMRE.Math.Operations.AngleCrossProduct(verts, 3, 0, 1);
                //float3 cross1 = Unity.Mathematics.math.cross(verts[3] - verts[0], verts[1] - verts[0]);
                //float3 cross1 = Unity.Mathematics.math.cross(verts[a] - verts[b], verts[c] - verts[b]);
                float3 cross1 = IMRE.Math.Operations.AngleCrossProduct(verts, 0, 1, 2);
                float3 cross2 = IMRE.Math.Operations.AngleCrossProduct(verts, 1, 2, 3);
                float3 cross3 = IMRE.Math.Operations.AngleCrossProduct(verts, 2, 3, 0);

                int[] tris = { 0, 1, 2, 0, 2, 3 };
                if (!(cross0.Equals(cross1) && cross1.Equals(cross2) && cross2.Equals(cross3)))
                {
                    //assume 0,1,3,2
                    cross0 = IMRE.Math.Operations.AngleCrossProduct(verts, 2, 0, 1);
                    cross1 = IMRE.Math.Operations.AngleCrossProduct(verts, 0, 1, 3);
                    cross2 = IMRE.Math.Operations.AngleCrossProduct(verts, 1, 3, 2);
                    cross3 = IMRE.Math.Operations.AngleCrossProduct(verts, 3, 2, 0);

                    tris = new int[] { 0, 1, 3, 0, 3, 2 };

                    if (!(cross0.Equals(cross1) && cross1.Equals(cross2) && cross2.Equals(cross3)))
                    {
                        //assume 0,2,1,3 (switch 1 and 2)
                        cross0 = IMRE.Math.Operations.AngleCrossProduct(verts, 3, 0, 2);
                        cross1 = IMRE.Math.Operations.AngleCrossProduct(verts, 0, 2, 1);
                        cross2 = IMRE.Math.Operations.AngleCrossProduct(verts, 2, 1, 3);
                        cross3 = IMRE.Math.Operations.AngleCrossProduct(verts, 1, 3, 0);
                        if (!(cross0.Equals(cross1) && cross1.Equals(cross2) && cross2.Equals(cross3)))
                        {
                            UnityEngine.Debug.LogWarning("failed check on vertex ordering");
                        }
                        tris = new int[] { 0, 2, 1, 0, 1, 3 };
                    }
                }
                tetrahedronMesh.triangles = tris;
            }
        }