Back to class index
| Polygon::DiagonalSyntaxLineSegment Polygon::Diagonal(int i, int j) const; [12 lines of code]Returns the diagonal that joins the two given vertices. If |i-j| == 1, then this returns an edge of this Polygon. If i==j, then a degenerate line segment of zero length is returned. Otherwise, the line segment that joins the two given vertices is returned. Note that if the polygon is not planar or convex, this line segment might not lie inside the polygon. Use the DiagonalExists() function to test whether the returned LineSegment actually is a diagonal of this polygon. Note Whereas it is invalid to call DiagonalExists() with values |i-j|<=1, it is acceptable for this function. This is to simplify generation of code that iterates over diagonal vertex pairs. ParametersintiIndex of the first endpoint of the diagonal LineSegment, in the range [0, NumVertices-1]. intjIndex of the second endpoint of the diagonal LineSegment, in the range [0, NumVertices-1]. Return ValueLineSegment(Vertex(i), Vertex(j)) without checking if this actually is a valid diagonal of this polygon. If indices outside the valid range are passed, LineSegment(nan, nan) is returned. See Also |