Exemple #1
0
        public static bool IsLineInsectCirclePlane2(Vector3 line1, Vector3 line2, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointArrayInfo insect)
        {
            Vector3 l1       = plane.TransformToLocal(line1);
            Vector3 l2       = plane.TransformToLocal(line2);
            Vector3 c1       = plane.TransformToLocal(center);
            bool    isInsect = IsLineInsectCircle2(new Vector2(l1.x, l1.z), new Vector2(l2.x, l2.z), new Vector2(c1.x, c1.z), r, ref insect);

            if (isInsect)
            {
                insect.mHitGlobalPoint.mPointArray = GeoPlaneUtils.PlaneTransformGlobal(insect.mHitGlobalPoint.mPointArray, plane);
            }
            return(insect.mIsIntersect);
        }
Exemple #2
0
        public static bool IsAABBInsectCirclePlane2(Vector3 min, Vector3 max, Vector3 center, float r, GeoPlane plane, ref GeoInsectPointArrayInfo insect)
        {
            Vector3 min1     = plane.TransformToLocal(min);
            Vector3 max1     = plane.TransformToLocal(max);
            Vector3 c1       = plane.TransformToLocal(center);
            bool    isInsect = IsAABBInsectCircle2(min1, max1, c1, r, ref insect);

            if (isInsect)
            {
                insect.mHitGlobalPoint.mPointArray = GeoPlaneUtils.PlaneTransformGlobal(insect.mHitGlobalPoint.mPointArray, plane);
            }
            return(isInsect);
        }
Exemple #3
0
        public static bool IsLineInsectAABBPlane2(Vector3 line1, Vector3 line2, Vector3 min, Vector3 max, GeoPlane plane, ref GeoInsectPointArrayInfo insect)
        {
            Vector3 min1     = plane.TransformToLocal(min);
            Vector3 max1     = plane.TransformToLocal(max);
            Vector3 l1       = plane.TransformToLocal(line1);
            Vector3 l2       = plane.TransformToLocal(line2);
            bool    isInsect = IsLineInsectAABB2(new Vector2(l1.x, l1.z), new Vector2(l2.x, l2.z), new Vector2(min1.x, min1.z), new Vector2(max1.x, max1.z), ref insect);

            if (isInsect)
            {
                insect.mHitGlobalPoint.mPointArray = GeoPlaneUtils.PlaneTransformGlobal(insect.mHitGlobalPoint.mPointArray, plane);
            }
            return(isInsect);
        }
Exemple #4
0
        public static bool IsSegmentInsectAABB2Plane(Vector3 seg1, Vector3 seg2, Vector3 min, Vector2 max, GeoPlane plane, ref GeoInsectPointArrayInfo insect)
        {
            Vector3 s1       = plane.TransformToLocal(seg1);
            Vector3 s2       = plane.TransformToLocal(seg2);
            Vector3 min1     = plane.TransformToLocal(min);
            Vector3 max1     = plane.TransformToLocal(max);
            bool    isInsect = IsSegmentInsectAABB2(s1, s2, min1, max1, ref insect);

            if (isInsect)
            {
                insect.mHitGlobalPoint.mPointArray = GeoPlaneUtils.PlaneTransformGlobal(insect.mHitGlobalPoint.mPointArray, plane);
            }
            return(isInsect);
        }
Exemple #5
0
        public static bool IsAABBInsectTriangle2Plane(Vector3 min, Vector3 max, GeoPlane plane, Vector3 p1, Vector3 p2, Vector3 p3, ref GeoInsectPointArrayInfo insect)
        {
            Vector2 p11, p21, p31;

            GeoPlaneUtils.PlaneTransformLocalTriangle(p1, p2, p3, plane, out p11, out p21, out p31);
            Vector3 vmin     = plane.TransformToLocal(min);
            Vector3 vmax     = plane.TransformToLocal(max);
            bool    isInsect = IsAABBInsectTriangle2(vmin, vmax, p11, p21, p31, ref insect);

            if (isInsect)
            {
                insect.mIsIntersect = true;
                insect.mHitGlobalPoint.mPointArray = GeoPlaneUtils.PlaneTransformGlobal(insect.mHitGlobalPoint.mPointArray, plane);
            }
            return(insect.mIsIntersect);
        }
Exemple #6
0
        public static GeoPointsArray3 BuildConvexHull(GeoPointsArray3 points)
        {
            points.Distinct();
            GeoPlane plane = new GeoPlane(Vector3.zero, 0);

            if (IsOnSamePlane(points, ref plane))
            {
                GeoPointsArray2 point2 = new GeoPointsArray2(GeoPlaneUtils.PlaneTransformLocal(points.mPointArray, plane));
                point2 = BuildConvexHull(point2);
                return(new GeoPointsArray3(GeoPlaneUtils.PlaneTransformGlobal(point2.mPointArray, plane)));
            }
            else
            {
                return(new GeoPointsArray3(QuickHull.BuildHull(points)));
            }
        }