static public IEnumerable <Vector3> GetTriangleIntersection(this Bounds item, Triangle3 triangle) { if (triangle.IsDegenerate() == false) { Plane plane = triangle.GetPlane(); if (plane.normal != Vector3.zero) { if (item.FullyContains(triangle)) { return(triangle.GetPoints()); } PlaneSpace plane_space = plane.GetPlaneSpace(); ConvexPolygon plane_polygon = new ConvexPolygon( plane_space.ProjectPoints(item.GetPlaneIntersection(plane)) ); ConvexPolygon triangle_polygon = new ConvexPolygon( plane_space.ProjectPoints(triangle.GetPoints()) ); return(plane_space.InflatePoints( plane_polygon.GetIntersection(triangle_polygon).GetVertexs() ).Narrow(p => item.Contains(p))); } } return(Empty.IEnumerable <Vector3>()); }
static public IEnumerable <LineSegment3> GetEdges(this Triangle3 item) { return(item.GetPoints().CloseLoop().Connect()); }
static public Vector3 GetCenter(this Triangle3 item) { return(item.GetPoints().Average()); }
static public Bounds GetBounds(this Triangle3 item) { return(BoundsExtensions.CreateWithPoints(item.GetPoints())); }