Construction of a Regular Polygon
The function
MbResultType RegularPolygon( const MbCartPoint3D & centre,
const MbCartPoint3D & point,
const MbVector3D & axisZ,
size_t vertexCount,
bool describe,
MbCurve3D *& result )
constructs a regular polygon inscribed in a specified circle or circumscribed about the circle.
The function parameters are:
centre — the center of the circle circumscribed about the equilateral polygon or inscribed in the equilateral polygon;
point — a point on the circle;
axisZ — the vector perpendicular to the circle plane;
vertexCount — the number of vertices of the polygon;
describe — the flag indicating a circumscribed or an inscribed polygon (true — a circumscribed polygon, false — an inscribed polygon).
The output parameter of the function is the constructed polyline curve result.
If successful, the function returns rt_Success, otherwise it returns an error code from the MbResultType enumeration.
The function is declared in the action_curve3d.h file.
The centre, point and axisZ parameters determine the circle in which the polygon with vertexCount vertices is inscribed (describe = false) or about which the polygon with vertexCount vertices is circumscribed (describe = true). The center of the circle is located at point centre, the circle passes through point, and the axis of the circle is parallel to the axisZ vector.
The vertexCount parameter determines the number of vertices of the regular polygon:
if vertexCount == 0, a circle centered at centre and passing through point is constructed;
if vertexCount == 1, a line segment with endpoints at centre and point is constructed;
if vertexCount == 2, a rectangle with sides parallel to the global axes and with opposite vertices at centre and point is constructed;
if vertexCount >= 3, a regular polygon with the specified number of sides is constructed, inscribed in the circle (describe == false) or circumscribed about the circle (describe == true) centered at centre and passing through point.
The constructed curve is a closed polyline described in section MbPolyline3D Polyline (for vertexCount >= 3). Fig. 1 shows a regular polygon inscribed in a circle, and Fig. 2 shows a regular polygon circumscribed about a circle:
Fig. 1
Fig. 2