CSPrimPolygon
- class CSXCAD.CSPrimitives.CSPrimPolygon
Bases:
CSPrimitives
Polygon Primitive
A polygon is a surface defined by a set of 2D points/coordinates. To place the polygon in a 3D space, a normal direction (x/y/z) and an elevation in this direction have to be specified.
- Parameters:
- points(N,2) array
Array of coordinates
- norm_dirfloat or str
Normal direction, either 0,1,2 or x/y/z respectively
- elevationfloat
Elevation in normal direciton
Examples
Define a half circle as polygon
>>> polygon = CSPrimitives.CSPrimBox(pset, metal, norm_dir='z', elevation=1.0) >>> ang = np.linspace(0, np.pi, 21) >>> polygon.SetCoords(5*np.cos(ang), 5*np.sin(ang))
- ClearCoords()
Remove all coordinates.
- GetCoords()
Get the coordinates for the polygon
- Return x0, x1:
(N,), (N,) Arrays for x0,x1 of the polygon coordinates
- GetElevation()
Get the elevation in normal direction.
- Return val:
float – Get the elevation in normal direction.
- GetNormDir()
Get the normal direction.
- Return ny:
int – Normal direction as 0, 1 or 2 meaning x,y or z
- GetQtyCoords()
Get the number of coordinates for the polygon
- Return val:
int – Number of polygon coordinates.
- SetCoords(x0, x1)
Set the coordinates for the polygon. This will clear all previous coordinates.
- Parameters:
x1 (x0,) – (N,), (N,) Two arrays for x0/x1 of the polygon coordinates.
- SetElevation(val)
Set the elevation in normal direction.
- Parameters:
val – float – Elevation in normal direction.
- SetNormDir(ny)
Set the normal direction.
- Parameters:
ny – int or string – Normal direction, either 0/1/2 or ‘x’/’y’/’z’