All shapes (primitives or the results of operations) can be passed to hull functions to determine the convex hull of all points. In all cases, the function returns the results, and never changes the original shapes.
Example
const { hull, hullChain } = require('@jscad/modeling').hulls
Methods
(static) hull(…geometries) → {geom2|geom3}
Create a convex hull of the given geometries. The given geometries should be of the same type, either geom2 or geom3 or path2.
Examples
let myshape = hull(rectangle({center: [-5,-5]}), ellipse({center: [5,5]}))
+-------+ +-------+
| | | \
| A | | \
| | | \
+-------+ + \
= \ \
+-------+ \ +
| | \ |
| B | \ |
| | \ |
+-------+ +-------+
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
geometries |
Objects |
<repeatable> |
list of geometries from which to create a hull |
Returns:
new geometry
(static) hullChain(…geometries) → {geom2|geom3}
Create a chain of hulled geometries from the given geometries. Essentially hull A+B, B+C, C+D, etc., then union the results. The given geometries should be of the same type, either geom2 or geom3 or path2.
Examples
let newshape = hullChain(rectangle({center: [-5,-5]}), circle({center: [0,0]}), rectangle({center: [5,5]}))
+-------+ +-------+ +-------+ +------+
| | | | | \ / |
| A | | C | | | |
| | | | | |
+-------+ +-------+ + +
= \ /
+-------+ \ /
| | \ /
| B | \ /
| | \ /
+-------+ +-------+
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
geometries |
Objects |
<repeatable> |
list of geometries from which to create a hull |
Returns:
new geometry
(static) hullPoints2(uniquePoints) → {Array}
- Source:
- See:
Create a convex hull of the given set of points, where each point is an array of [x,y].
Parameters:
Name | Type | Description |
---|---|---|
uniquePoints |
Array | list of UNIQUE points from which to create a hull |
Returns:
a list of points that form the hull
- Type
- Array
(static) hullPoints3(uniquePoints) → {Array}
Create a convex hull of the given set of points, where each point is an array of [x,y,z].
Parameters:
Name | Type | Description |
---|---|---|
uniquePoints |
Array | list of UNIQUE points from which to create a hull |
Returns:
a list of polygons (poly3)
- Type
- Array