Exemplo n.º 1
0
        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>());
        }
Exemplo n.º 2
0
 static public IEnumerable <LineSegment3> GetEdges(this Triangle3 item)
 {
     return(item.GetPoints().CloseLoop().Connect());
 }
Exemplo n.º 3
0
 static public Vector3 GetCenter(this Triangle3 item)
 {
     return(item.GetPoints().Average());
 }
Exemplo n.º 4
0
 static public Bounds GetBounds(this Triangle3 item)
 {
     return(BoundsExtensions.CreateWithPoints(item.GetPoints()));
 }