public BoundingBox(Tri2 t) { MinX = t.Vertices.Min(p => p.X); MaxX = t.Vertices.Max(p => p.X); MinY = t.Vertices.Min(p => p.Y); MaxY = t.Vertices.Max(p => p.Y); }
public Tri3 PaperToSpace(Tri2 t) { return(new Tri3( PaperToSpace(t.A.X, t.A.Y), PaperToSpace(t.B.X, t.B.Y), PaperToSpace(t.C.X, t.C.Y))); }
public BothTri(Tri3 space, Transform spaceToPaper) { Space = space; Index = space.Index; Paper = spaceToPaper.Apply(space).AsTri2(); SpaceToPaper = spaceToPaper; paperToSpace = spaceToPaper.Inv(); }
// Check if two triangles intersect public bool TriangleIntersection(Tri2 t2, double epsilon) { if (LineIntersection(A, B, t2.A, t2.B, epsilon)) { return(true); } if (LineIntersection(A, B, t2.A, t2.C, epsilon)) { return(true); } if (LineIntersection(A, B, t2.B, t2.C, epsilon)) { return(true); } if (LineIntersection(A, C, t2.A, t2.B, epsilon)) { return(true); } if (LineIntersection(A, C, t2.A, t2.C, epsilon)) { return(true); } if (LineIntersection(A, C, t2.B, t2.C, epsilon)) { return(true); } if (LineIntersection(B, C, t2.A, t2.B, epsilon)) { return(true); } if (LineIntersection(B, C, t2.A, t2.C, epsilon)) { return(true); } if (LineIntersection(B, C, t2.B, t2.C, epsilon)) { return(true); } if (PointInTriangle(t2.A, epsilon) && PointInTriangle(t2.B, epsilon) && PointInTriangle(t2.C, epsilon)) { return(true); } if (t2.PointInTriangle(A, epsilon) && t2.PointInTriangle(B, epsilon) && t2.PointInTriangle(C, epsilon)) { return(true); } return(false); }