Exemple #1
0
        public static bool Project2(EdgeAbstract edge_A, EdgeAbstract edge_B, float maxDist, Axis axis, out Vector3 intersectionA, out Vector3 intersectionB)
        {
            Vector2 a1 = new Vector2(axis == Axis.x ? edge_A.a.x : edge_A.a.z, edge_A.a.y);
            Vector2 a2 = new Vector2(axis == Axis.x ? edge_A.b.x : edge_A.b.z, edge_A.b.y);

            Vector2 b1 = new Vector2(axis == Axis.x ? edge_B.a.x : edge_B.a.z, edge_B.a.y);
            Vector2 b2 = new Vector2(axis == Axis.x ? edge_B.b.x : edge_B.b.z, edge_B.b.y);

            Vector2 i1, i2;

            if (SomeMath.TwoLinesProjectionByX(a1, a2, b1, b2, maxDist, out i1, out i2))
            {
                if (axis == Axis.x)
                {
                    intersectionA = new Vector3(i1.x, i1.y, edge_A.a.z);
                    intersectionB = new Vector3(i2.x, i2.y, edge_A.a.z);
                }
                else
                {
                    intersectionA = new Vector3(edge_A.a.x, i1.y, i1.x);
                    intersectionB = new Vector3(edge_A.a.x, i2.y, i2.x);
                }

                return(true);
            }
            else
            {
                intersectionA = Vector3.zero;
                intersectionB = Vector3.zero;
                return(false);
            }
        }
Exemple #2
0
        public static bool Project(CellContentData data_A, CellContentData data_B, float maxDist, Axis axis, out CellContentData intersection)
        {
            Vector2 a1 = new Vector2(axis == Axis.x ? data_A.a.x : data_A.a.z, data_A.a.y);
            Vector2 a2 = new Vector2(axis == Axis.x ? data_A.b.x : data_A.b.z, data_A.b.y);

            Vector2 b1 = new Vector2(axis == Axis.x ? data_B.a.x : data_B.a.z, data_B.a.y);
            Vector2 b2 = new Vector2(axis == Axis.x ? data_B.b.x : data_B.b.z, data_B.b.y);

            Vector2 i1, i2;

            if (SomeMath.TwoLinesProjectionByX(a1, a2, b1, b2, maxDist, out i1, out i2))
            {
                if (axis == Axis.x)
                {
                    intersection = new CellContentData(new Vector3(i1.x, i1.y, data_A.a.z), new Vector3(i2.x, i2.y, data_A.a.z));
                }
                else
                {
                    intersection = new CellContentData(new Vector3(data_A.a.x, i1.y, i1.x), new Vector3(data_A.a.x, i2.y, i2.x));
                }
                return(true);
            }
            else
            {
                intersection = new CellContentData(Vector3.zero);
                return(false);
            }
        }
Exemple #3
0
        public static bool Project2(CellContentData data_A, CellContentData data_B, float maxDist, Axis axis, out CellContentData intersection,
                                    ref List <CellContentData> aSideOutput, ref List <CellContentData> bSideOutput)
        {
            Vector3 aa = data_A.a;
            Vector3 ab = data_A.b;

            Vector3 ba = data_B.a;
            Vector3 bb = data_B.b;

            if (aa.x > ab.x)
            {
                Vector3 temp = ab;
                ab = aa;
                aa = temp;
            }

            if (ba.x > bb.x)
            {
                Vector3 temp = bb;
                bb = ba;
                ba = temp;
            }

            Vector2 a1 = new Vector2(axis == Axis.x ? aa.x : aa.z, aa.y);
            Vector2 a2 = new Vector2(axis == Axis.x ? ab.x : ab.z, ab.y);

            Vector2 b1 = new Vector2(axis == Axis.x ? ba.x : ba.z, ba.y);
            Vector2 b2 = new Vector2(axis == Axis.x ? bb.x : bb.z, bb.y);



            Vector2 minus, plus;

            if (SomeMath.TwoLinesProjectionByX(a1, a2, b1, b2, maxDist, out minus, out plus))
            {
                if (axis == Axis.x)
                {
                    intersection = new CellContentData(new Vector3(minus.x, minus.y, data_A.a.z), new Vector3(plus.x, plus.y, data_A.a.z));
                }
                else
                {
                    intersection = new CellContentData(new Vector3(data_A.a.x, minus.y, minus.x), new Vector3(data_A.a.x, plus.y, plus.x));
                }


                bSideOutput.Add(intersection);
                aSideOutput.Add(intersection);

                if (intersection.xLeft > aa.x)
                {
                    aSideOutput.Add(new CellContentData(aa, intersection.leftV3));
                }
                if (intersection.xRight < ab.x)
                {
                    aSideOutput.Add(new CellContentData(ab, intersection.rightV3));
                }


                if (intersection.xLeft > ba.x)
                {
                    aSideOutput.Add(new CellContentData(ba, intersection.leftV3));
                }
                if (intersection.xRight < bb.x)
                {
                    aSideOutput.Add(new CellContentData(bb, intersection.rightV3));
                }

                return(true);
            }
            else
            {
                intersection = new CellContentData(Vector3.zero);
                return(false);
            }
        }