project
Queries · api.md § project · all operations
definition
project(s: Solid, direction: Vector3, tolerance: Length) -> {visible: list<list<Point2>>, hidden: list<list<Point2>>}
Makes a hidden-line drawing of the solid seen looking along direction. The drawing shows the solid's edges, and its outlines where the line of sight grazes a curved face. Each edge and each outline is cut into the stretches the viewer sees and the stretches the solid hides. A point is hidden when the ray from that point toward the viewer passes through the solid. An edge between faces that meet smoothly is not drawn, and neither is a face's seam.
Each stretch is returned as a polyline in the view plane. Every vertex of the polyline lies on the stretch, and every chord lies within tolerance of the stretch. tolerance must be positive. The plane has two axes. The axis across is u = d × z, made unit, or d × x when d runs along z. The axis up is v = −d × u. A point p draws at (p·u, p·v).
Example. Solid 1 is a 10 × 20 × 30 mm box with one corner at the origin.
> {"cmd": "project", "s": 1, "direction": [0, 0, -1], "tolerance": 0.01}
< {"ok": {"hidden": [], "visible": [[[0.0, 0.0], [0.0, 0.625], [0.0, 1.25], [0.0, 1.875],
[0.0, 2.5], [0.0, 3.125], … 11 more], [[0.0, 0.0], [0.0, 0.625], [0.0, 1.25], [0.0, 1.875],
[0.0, 2.5], [0.0, 3.125], … 11 more], [[0.0, 10.0], [-1.25, 10.0], [-2.5, 10.0], [-3.75, 10.0],
[-5.0, 10.0], [-6.25, 10.0], … 11 more], [[0.0, 10.0], [-1.25, 10.0], [-2.5, 10.0],
[-3.75, 10.0], [-5.0, 10.0], [-6.25, 10.0], … 11 more], [[-20.0, 10.0], [-20.0, 9.375],
[-20.0, 8.75], [-20.0, 8.125], [-20.0, 7.5], [-20.0, 6.875], … 11 more], [[-20.0, 10.0],
[-20.0, 9.375], [-20.0, 8.75], [-20.0, 8.125], [-20.0, 7.5], [-20.0, 6.875], … 11 more],
… 6 more]}}common to queries
| Function | Fields | Returns |
|---|---|---|
volume | s | Volume |
area | s | Area |
classify | s, points | list<"in" or "on" or "out"> |
closest | s, points | list<Point3> |
normal | s, points | list<Vector3 or null> |
curvature | s, points | list<Number[2] or null> |
check | s | list<string> |
centroid | s | Point3 or null |
inertia | s | Number[3][3] |
distance | a, b | Length |
interference | a, b | {volume: Volume, gap: Length} |
betti | s | Count[3] |
section_area | s, origin, normal | Area |
section | s, origin, normal, tolerance | list<list<Point3>> |
project | s, direction, tolerance | {visible: list<list<Point2>>, hidden: list<list<Point2>>} |
bounding_box | s | Point3[2] |
split | s, origin, normal | Solid[2] |
mesh | s, tolerance | {positions: list<Point3>, triangles: list<Index[3]>} |
display | s, tolerance | {faces: list<Face>, edges: list<list<Point3>>} |
raycast | s, origin, direction; or s, rays | list<Length>; or list<list<Length>> |