Provide functions for creating simple polygons.
Signature | Description |
---|---|
taiwan(h[,distance]) |
Create a convex hull through the provided points. |
regularPolygon(nSides,radius[,thetaStart,thetaEnd]) |
Create a regular polygon. |
star([outerRadius,innerRadius,n]) |
Create a star. |
hull2D(points) |
Create a convex hull through the provided points. |
Create a Taiwan profile.
h
: The height of Taiwan.distance = 0
: used for simplifying the shape. If the distance between a point and its previous points is not greater than distance, the point will be kept.
from cqmore import Workplane
from cqmore.polygon import taiwan
taiwan = (Workplane()
.makePolygon(taiwan(20))
.extrude(1)
)
Create a regular polygon.
nSides
: number of sides.radius
: the size of the polygon.thetaStart = 0
: start angle for the first segment.thetaEnd = 360
: end angle for the last segment.
from cqmore import Workplane
from cqmore.polygon import regularPolygon
polygon = (Workplane()
.makePolygon(regularPolygon(nSides = 6, radius = 10))
.extrude(1)
)
from cqmore import Workplane
from cqmore.polygon import regularPolygon
polygon = (Workplane()
.makePolygon(
regularPolygon(
nSides = 6,
radius = 10,
thetaStart = 45,
thetaEnd = 270
)
)
.extrude(1)
)
Create a star. Default to a pentagram.
outerRadius = 1
: the outer radius of the star.innerRadius = 0.381966
: the inner radius of the star.n = 5
: the burst number.
from cqmore import Workplane
from cqmore.polygon import star
polygon = (Workplane()
.makePolygon(
star(outerRadius = 10, innerRadius = 5, n = 8)
)
.extrude(1)
)
Create a convex hull through the provided points.
points
: a list of x, y points.
from random import random
from cqmore import Workplane
from cqmore.polygon import hull2D
points = [(random(), random()) for i in range(20)]
convex_hull = Workplane().makePolygon(hull2D(points))