raycast
Queries · api.md § raycast · all operations
definition
raycast(s: Solid, origin: Point3, direction: Vector3) -> list<Length>
raycast(s: Solid, rays: list<[Point3, Vector3]>) -> list<list<Length>>
Finds where a ray meets the solid's faces. It returns the distance from origin to each meeting, in mm, in any order. direction need not be a unit vector. A ray through an edge or a vertex meets every face there, and a kernel may list that point once for each face. A client reads meetings within 10·ε of each other as one crossing. A request may carry many rays at once by giving rays, a list of [origin, direction] pairs, in place of origin and direction. The reply is then one list of distances for each ray, in the rays' order. An adapter that reads only one ray per request refuses the many-ray form, and the client falls back to one request per ray.
Example. Solid 1 is a 10 × 20 × 30 mm box with one corner at the origin.
> {"cmd": "raycast", "s": 1, "origin": [-5, 10, 15], "direction": [1, 0, 0]}
< {"ok": [5.0, 15.0]}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>> |