Paths
Smooth Paths
Builds a cubic Hermite curve and provides distance-aware sampling utilities.
build_smooth() generates missing tangents, constructs the native PathConstraintPathHermite, transports a stable normal along the curve, applies each point's roll, and builds an approximate arc-length table.
Syntax#
track.build_smooth(smoothness=1.0);Requirements#
| Property | Requirement |
|---|---|
| smoothness | Finite, greater than 0, and at most 4. |
| open path | At least 2 control points. |
| looping path | At least 3 control points. |
| segments | Consecutive positions must differ. |
Automatic tangent rule#
- Interior open-path and all loop tangents use 0.5 × smoothness × (next − previous).
- Open-path endpoints use smoothness times their adjacent segment.
- Tangents added with add_point_tangent() are preserved.
Sampling by arc length#
var midpoint = track.get_position(0.5);
var direction = track.get_direction(0.5);
var distance = track.get_length() * 0.25;
var position = track.get_position_at_distance(distance);
var tangent = track.get_direction_at_distance(distance);Public fractions represent normalized approximate arc length, not the raw per-segment Hermite parameter. Fraction 0.5 is therefore the physical midpoint of the path.
Frames and spatial queries#
var euler = track.get_rotation(0.5);
var quaternion = track.get_rotation_quaternion(0.5);
var nearest = track.get_closest_point(x, y, z);
var bounds = track.get_bounds();| Closest-point field | Meaning |
|---|---|
| position | Nearest sampled Hermite position. |
| distance | World-space distance from the query point. |
| fraction | Normalized arc-length fraction. |
| path_distance | Distance along the path. |
| direction | Path tangent at the closest position. |
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| JoltPath.build_smooth | JoltPath.build_smooth(smoothness = 1.0) | Boolean; smoothness(0, 4] default 1, at least2 open/3 loop points. Computes implicit tangents and builds a new native resource. An invalid build cannot be sampled. |
| JoltPath.get_bounds | JoltPath.get_bounds() | After build:length m(error0), copied bounds min_x/y/z, max_x/y/z(error undefined) in path coordinates. |
| JoltPath.get_closest_point | JoltPath.get_closest_point(x, y, z) | XYZ in path coordinates, after build; snapshot {position, distance, fraction, path_distance, direction}. Distance from query and path_distance along curve in m; undefined on error. |
| JoltPath.get_direction | JoltPath.get_direction(fraction) | Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected. |
| JoltPath.get_direction_at_distance | JoltPath.get_direction_at_distance(distance) | Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected. |
| JoltPath.get_length | JoltPath.get_length() | After build:length m(error0), copied bounds min_x/y/z, max_x/y/z(error undefined) in path coordinates. |
| JoltPath.get_position | JoltPath.get_position(fraction) | Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected. |
| JoltPath.get_position_at_distance | JoltPath.get_position_at_distance(distance) | Requires current build; fraction0..1 or finite distance m. Returns {x, y, z} position m / unit tangent in path coordinates, undefined when rejected. |
| JoltPath.get_rotation | JoltPath.get_rotation(fraction) | Fraction0..1 after build; XYZW quaternion only from get_rotation_quaternion. Both get_rotation and get_rotation_euler return Euler XYZ°! undefined on error. |
| JoltPath.get_rotation_euler | JoltPath.get_rotation_euler(fraction) | Fraction0..1 after build; XYZW quaternion only from get_rotation_quaternion. Both get_rotation and get_rotation_euler return Euler XYZ°! undefined on error. |
| JoltPath.get_rotation_quaternion | JoltPath.get_rotation_quaternion(fraction) | Fraction0..1 after build; XYZW quaternion only from get_rotation_quaternion. Both get_rotation and get_rotation_euler return Euler XYZ°! undefined on error. |