public static bool IsOnSamePlane(GeoPointsArray3 points, ref GeoPlane plane) { if (points.Size() < 4) { return(true); } int count = points.Size(); int i = 2; Vector3 p = points[0]; for (; i < count; ++i) { p = points[i]; if (!GeoLineUtils.IsPointInLine3(points[0], points[1], ref p)) { break; } } if (i == count) { return(true); } plane = GeoPlaneUtils.CreateFromTriangle(points[0], points[1], p); i = 2; int c = 2; for (; i < count; ++i) { if (GeoPlaneUtils.IsPointOnPlane(plane.mNormal, plane.mD, points[i])) { c++; } } return(c == count); }
public QuickHull(GeoPointsArray3 points) { mPoints = points; mPoints.Distinct(); mVertexCount = mPoints.Size(); mTrianglePlanePoints = new List <QHullTrianglePlanePoints>(); }
public static List <Vector3> BuildHull(GeoPointsArray3 points) { QuickHull qHull = new QuickHull(points); qHull.BuildHull(); return(qHull.GetTriangles()); }
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))); } }
public GeoPointsArray3 mHitGlobalPoint; // if Vector2, then add 0 to z public GeoInsectPointArrayInfo() { mIsIntersect = false; mLength = 0.0f; mHitGlobalPoint = new GeoPointsArray3(); }