sdf/primitives
src/sdf/primitives.tur
smart constructors for SDF leaf shapes.
Since: Phase 1
defn
sdf-sphere
(sdf-sphere [cx : float cy : float cz : float r : float] :)
sphere centred at (cx,cy,cz) with radius r.
Parameters
| cx cy cz -- centre position | ||
| r | radius (> 0) |
Returns
SdfExpr handle.
Example
(sdf-sphere 0.0 0.0 0.0 1.5)
Since: Phase 1
defn
sdf-box
(sdf-box [lx : float ly : float lz : float hx : float hy : float hz : float] :)
axis-aligned box from corner lo=(lx,ly,lz) to hi=(hx,hy,hz).
Parameters
| lx ly lz -- minimum corner | ||
| hx hy hz -- maximum corner |
Returns
SdfExpr handle.
Example
(sdf-box -1.0 -1.0 -1.0 1.0 1.0 1.0)
Since: Phase 1
defn
sdf-cylinder
(sdf-cylinder [cx : float cy : float cz : float r : float] :)
infinite cylinder along +Z axis, projected radius r.
Parameters
| cx cy cz -- axis centre (z component ignored for distance, used for translate) | ||
| r | radius (> 0) |
Returns
SdfExpr handle.
Example
(sdf-cylinder 0.0 0.0 0.0 0.5)
Since: Phase 1
defn
sdf-plane
(sdf-plane [nx : float ny : float nz : float d : float] :)
infinite plane n.p + d = 0.
Parameters
| nx ny nz -- outward normal (unit length recommended) | ||
| d | plane offset (distance from origin along -n direction) |
Returns
SdfExpr handle.
Example
(sdf-plane 0.0 1.0 0.0 0.0) ; floor at y = 0 (sdf-plane 0.0 1.0 0.0 -2.0) ; floor at y = 2
Since: Phase 1
defn
sdf-torus
(sdf-torus [cx : float cy : float cz : float big-r : float small-r : float] :)
torus centred at (cx,cy,cz) in the XZ plane.
Parameters
| cx cy cz -- centre position | ||
| big-r | ring radius (distance from centre to tube centre) | |
| small-r | tube cross-section radius |
Returns
SdfExpr handle.
Example
(sdf-torus 0.0 0.0 0.0 1.5 0.3)
Since: Phase 5
defn
sdf-capsule
(sdf-capsule [ax : float ay : float az : float bx : float by : float bz : float r : float] :)
capsule (cylinder with hemispherical caps) from A to B.
Parameters
| ax ay az -- endpoint A | ||
| bx by bz -- endpoint B | ||
| r | capsule radius |
Returns
SdfExpr handle.
Example
(sdf-capsule 0.0 -1.0 0.0 0.0 1.0 0.0 0.4)
Since: Phase 5