Transforms API

Positioning, rotation, scale, symmetry, and math helpers.

Transforms

translate

method

Moves the shape by an offset.

sdf.translate(x: f64, y: f64, z: f64) -> Sdf
sphere(0.5).translate(1.0, 0.0, 0.0)

translate_x

method

Moves the shape along the X axis.

sdf.translate_x(x: f64) -> Sdf
sphere(0.5).translate_x(1.0)

translate_y

method

Moves the shape along the Y axis.

sdf.translate_y(y: f64) -> Sdf
sphere(0.5).translate_y(1.0)

translate_z

method

Moves the shape along the Z axis.

sdf.translate_z(z: f64) -> Sdf
sphere(0.5).translate_z(1.0)

rotate_x

method

Rotates the shape around the X axis in radians.

sdf.rotate_x(angle: f64) -> Sdf
cube(0.5).rotate_x(deg(45.0))

rotate_y

method

Rotates the shape around the Y axis in radians.

sdf.rotate_y(angle: f64) -> Sdf
cube(0.5).rotate_y(deg(45.0))

rotate_z

method

Rotates the shape around the Z axis in radians.

sdf.rotate_z(angle: f64) -> Sdf
cube(0.5).rotate_z(deg(45.0))

scale

method

Uniformly scales the shape.

sdf.scale(factor: f64) -> Sdf
sphere(0.5).scale(2.0)

mirror_x

method

Mirrors the shape across the YZ plane.

sdf.mirror_x() -> Sdf
sphere(0.5).translate_x(0.5).mirror_x()

mirror_y

method

Mirrors the shape across the XZ plane.

sdf.mirror_y() -> Sdf
sphere(0.5).translate_y(0.5).mirror_y()

mirror_z

method

Mirrors the shape across the XY plane.

sdf.mirror_z() -> Sdf
sphere(0.5).translate_z(0.5).mirror_z()

symmetry_x

method

Creates X-axis symmetry.

sdf.symmetry_x() -> Sdf
sphere(0.5).translate_x(0.5).symmetry_x()

symmetry_y

method

Creates Y-axis symmetry.

sdf.symmetry_y() -> Sdf
sphere(0.5).translate_y(0.5).symmetry_y()

symmetry_z

method

Creates Z-axis symmetry.

sdf.symmetry_z() -> Sdf
sphere(0.5).translate_z(0.5).symmetry_z()

Math Helpers

PI

function

Returns pi.

PI() -> f64
cube(0.5).rotate_y(PI() / 4.0)

TAU

function

Returns 2*pi.

TAU() -> f64
cube(0.5).rotate_y(TAU() / 8.0)

deg

function

Converts degrees to radians.

deg(degrees: f64) -> f64
cube(0.5).rotate_x(deg(45.0))

rad

function

Converts radians to degrees.

rad(radians: f64) -> f64
let angle = rad(PI() / 4.0);