TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/danielitoCode/Spatial/llms.txt
Use this file to discover all available pages before exploring further.
spatial-units module provides two inline value classes — Distance and Angle — that carry type-level unit information into Modifier3D, rememberCameraState, and all camera control APIs. Using these types instead of raw Float values prevents unit-mismatch bugs at compile time and makes scene code read as natural human measurements: 2f.meters, 50.cm, 45f.deg.
Import
spatial-units
Distance
Distance is a JVM inline value class that wraps a single Float stored in meters. The private constructor means you cannot construct a Distance directly — use the companion factory methods or the extension properties on Int and Float.
Declaration
Companion factory methods
Creates a
Distance from a value already expressed in meters.Creates a
Distance from a value expressed in centimeters. The value is divided by 100f before storage so the underlying representation is always in meters.Extension properties
Converts an
Int literal to a Distance in meters via Distance.meters(toFloat()).Converts a
Float literal to a Distance in meters via Distance.meters(this).Converts an
Int literal representing centimeters to a Distance via Distance.centimeters(toFloat()).Converts a
Float literal representing centimeters to a Distance via Distance.centimeters(this).Operators
Both arithmetic operators return a newDistance:
| Operator | Signature | Description |
|---|---|---|
+ | operator fun plus(other: Distance): Distance | Adds two distances. |
- | operator fun minus(other: Distance): Distance | Subtracts two distances. |
Reading the raw value
val meters: Float is the single backing property on the inline class. Because Distance is an inline class, accessing .meters at runtime has zero overhead — no boxing occurs.
Angle
Angle is a JVM inline value class that wraps a single Float stored in radians. All degree-based input is converted to radians at construction time via the PI / 180.0 factor.
Declaration
Companion factory methods
Creates an
Angle from a value already expressed in radians.Creates an
Angle from a value in degrees. Internally computes (value * PI / 180.0).toFloat() and stores the result as radians.Extension properties
Converts an
Int literal in degrees to an Angle via Angle.degrees(toFloat()).Converts a
Float literal in degrees to an Angle via Angle.degrees(this).Reading the raw value
val radians: Float is the single backing property. Degrees-to-radians conversion happens once at construction; no conversion overhead occurs on subsequent reads.
Quick reference
| Expression | Input type | Input unit | Return type | Stored as |
|---|---|---|---|---|
n.meters | Int | meters | Distance | meters |
f.meters | Float | meters | Distance | meters |
n.cm | Int | centimeters | Distance | meters |
f.cm | Float | centimeters | Distance | meters |
n.deg | Int | degrees | Angle | radians |
f.deg | Float | degrees | Angle | radians |
Distance.meters(f) | Float | meters | Distance | meters |
Distance.centimeters(f) | Float | centimeters | Distance | meters |
Angle.radians(f) | Float | radians | Angle | radians |
Angle.degrees(f) | Float | degrees | Angle | radians |