shapes.arc#
- shapes.arc(angle=None, radius=1.0, center=(0.0, 0.0, 0.0), div=None, eltype='line2', elsize=None, start=None, end=None, direction='ccw')#
Create a polygonal arc in a plane parallel to the xy-plane.
The arc lies in a plane parallel to the xy-plane and is defined relative to the given center. The arc is generated by sweeping either a given angular extent or between two absolute angles (start and end). The sweep direction can be explicitly controlled.
Two construction modes are supported:
1. angle mode: The arc starts at angle 0° (positive x-axis) and is swept by a given angle.
2. start/end mode: The arc is defined between two absolute angles (in degrees).
Parameters#
- anglefloat, optional
Sweep angle in degrees starting from 0° along the positive x-axis. Use either angle OR (start, end), not both.
- radiusfloat, optional
Radius of the arc. Must be > 0. Default is 1.0.
- centerarray_like of shape (3,), optional
Coordinates of the arc center. Default is (0.0, 0.0, 0.0).
- divint, optional
Number of subdivisions (segments) along the arc. Must be >= 1. Default is 10.
- elsizefloat, optional
Target element size along the arc (mutually exclusive with div).
- eltype{“line2”, “tri3”}, optional
Element type of the returned mesh:
“line2”: returns only the arc contour as 2-node line elements.
“tri3”: returns a filled arc sector as 3-node triangular elements, formed by connecting the arc to the center.
- startfloat, optional
Starting angle in degrees (used with end). Normalized to [0, 360).
- endfloat, optional
Ending angle in degrees (used with start). Normalized to [0, 360).
- direction{“ccw”, “cw”}, optional
Sweep direction: - “ccw”: counterclockwise (positive angular sweep) - “cw”: clockwise (negative angular sweep)
Returns#
- Mesh
A mesh representing either the arc contour or a filled arc sector.
Examples#
Arc defined by sweep angle:
>>> A1 = arc(angle=180, radius=1.0, div=4) >>> print(A1.coords) [[ 1. 0. 0. ] [ 0.7071 0.7071 0. ] [ 0. 1. 0. ] [-0.7071 0.7071 0. ] [-1. 0. 0. ]]
Arc defined by start/end angles:
>>> A2 = arc(start=0, end=90, radius=1.0, div=4, direction="ccw") >>> print(A2.coords) [[1. 0. 0. ] [0.9239 0.3827 0. ] [0.7071 0.7071 0. ] [0.3827 0.9239 0. ] [0. 1. 0. ]]
Clockwise arc:
>>> A3 = arc(start=90, end=0, radius=1.0, div=4, direction="cw") >>> print(A3.coords) [[0. 1. 0. ] [0.3827 0.9239 0. ] [0.7071 0.7071 0. ] [0.9239 0.3827 0. ] [1. 0. 0. ]]
Filled sector:
>>> A4 = arc(angle=180, radius=1.0, div=3, eltype="tri3") >>> print(A4) Mesh: n_nodes: 5, n_elems: 3, plexitude: 3, level: 2, eltype: tri3 BBox: [-1. 0. 0.], [1. 0.866 0. ] Size: [2. 0.866 0. ] Length: 5.0 Area: 1.299
Using element size instead of number of divisions:
>>> A3 = arc(angle=90, radius=1.0, elsize=0.2) >>> print(A3.lengths()) [0.196 0.196 0.196 0.196 0.196 0.196 0.196 0.196]