.. role:: blue :class: blue Construction of a Regular Polygon ================================= .. _Construction_of_a_Regular_Polygon_: .. kernel version: 118058 The function .. code-block:: cpp 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 :blue:`rt_Success`, otherwise it returns an error code from the :ref:`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 :ref:`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: .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.5.1.png :width: 12cm :align: center Fig. 1 .. figure:: /MODELER/TWO-DIMENSIONAL_CURVE_CONSTRUCTION_METHODS/pictures/M.3.5.2.png :width: 12cm :align: center Fig. 2