Back to class index
Polygon[Class Summary]
p
ctor
NumEdges()[const]
NumVertices()[const]
VertexArrayPtr() (+1 overload)
AnyPointFast()[const]
Vertex(vertexIndex)[const]
Edge(edgeIndex)[const]
Edge2D(edgeIndex)[const]
EdgeNormal(edgeIndex)[const]
EdgePlane(edgeIndex)[const]
ExtremePoint(direction)[const] (+1 overload)
ProjectToAxis(...)[const]
DiagonalExists(i,j)[const]
Diagonal(i,j)[const]
IsConvex()[const]
IsPlanar(epsilonSq)[const]
IsSimple()[const]
IsNull()[const]
IsFinite()[const]
IsDegenerate(epsilon)[const]
BasisU()[const]
BasisV()[const]
MapTo2D(i)[const] (+1 overload)
MapFrom2D(point)[const]
NormalCCW()[const]
NormalCW()[const]
PlaneCCW()[const]
PlaneCW()[const]
Translate(offset)
Transform(transform) (+3 overloads)
Contains(...)[const] (+3 overloads)
Contains2D(...)[const]
Intersects(line)[const] (+11 overloads)
ConvexIntersects(aabb)[const] (+2 overloads)
ClosestPoint(...)[const] (+2 overloads)
Distance(point)[const]
Area()[const]
Perimeter()[const]
Centroid()[const]
CenterPoint()[const]
PointOnEdge(normalizedDistance)[const]
RandomPointOnEdge(rng)[const]
FastRandomPointInside(rng)[const]
ToPolyhedron()[const]
Triangulate()[const]
MinimalEnclosingAABB()[const]
ToString()[const]
SerializeToString()[const]
Equals(other)[const]
BitEquals(other)[const]
NumFaces()[static]
FromString(str,outEndStr)[static] (+1 overload)

Polygon::Diagonal

Syntax

LineSegment 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.

Parameters

intiIndex 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 Value

LineSegment(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

Vertex(), NumVertices(), DiagonalExists().