Constraints
Constraint Limits
Defines the legal positional or angular range independently for each supported constraint family.
Limit units and valid ranges are type-specific. Do not treat every JoltConstraint as if it accepted the same set_limits() signature.
Limit API by type#
| Type | Creation fields | Runtime methods | Units and validation |
|---|---|---|---|
| Hinge | limits_min / limits_max | set_limits(min,max), get_limits() | Degrees; finite and ordered. |
| Slider | limits_min / limits_max | set_limits(min,max), get_limits() | World units; minimum <= 0 <= maximum. |
| Distance | min_distance / max_distance | set_limits(min,max), get_limits() | World units; 0 <= minimum <= maximum. |
| Cone | max_angle | set_limit(angle), get_limit() | Single swing half-angle, 0..180 degrees. |
| SwingTwist | normal/plane half-angles, twist_min/max | set_limits(n,p,tmin,tmax), set_swing_limits(), set_twist_limits(), get_limits() | Degrees; swing 0..180, twist within -180..180 and ordered. |
| SixDOF | six axis fields | set_axis_limit(), set_translation_limits(), set_rotation_limits() | Linear world units; angular degrees within -180..180. |
| Pulley | min_length / max_length | set_length(min,max), length getters | Creation accepts -1 auto-resolution; runtime requires 0 <= min <= max. |
Fixed, free and limited#
- Equal Distance or Pulley bounds create an exact length.
- Slider zero is the relative creation pose, so the legal range must contain zero.
- Hinge -180..180 is effectively free rotation around its axis; equal limits lock the selected relative angle.
- SwingTwist 0-degree half-angles lock swing dimensions; 180 degrees is effectively free.
- SixDOF represents each axis explicitly as FIXED, FREE or LIMITED rather than inferring state from a numeric range.
SixDOF swing warning#
Rotation X is twist. Rotation Y/Z are coupled swing dimensions. CONE requires symmetric Y/Z limited ranges around zero, while PYRAMID permits asymmetric ranges. They are not independent Euler clamps.
Runtime example#
hinge.set_limits(0, 110); // degrees
slider.set_limits(-1.5, 1.5); // world units, contains zero
tether.set_limits(2, 4); // non-negative distance
cone.set_limit(35); // degrees
swing.set_twist_limits(-25, 25); // degrees
pulley.set_length(6, 8); // combined segment lengthVerified 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 |
|---|---|---|
| JoltConstraint.get_limit | JoltConstraint.get_limit() | Cone only: half-angle 0..180°; setter Boolean, getter number in degrees or 0 on error. |
| JoltConstraint.get_limits | JoltConstraint.get_limits() | {minimum, maximum} for Hinge (°), Distance/Slider (m); SwingTwist {normal_half_angle, plane_half_angle, twist_min, twist_max} (°). undefined for invalid/unsupported constraint or error. |
| JoltConstraint.get_rotation_limits_max | JoltConstraint.get_rotation_limits_max() | SixDOF {x, y, z}, translation in m / rotation in °. Composes individual getters; error components can be 0. |
| JoltConstraint.get_rotation_limits_min | JoltConstraint.get_rotation_limits_min() | SixDOF {x, y, z}, translation in m / rotation in °. Composes individual getters; error components can be 0. |
| JoltConstraint.get_translation_limits_max | JoltConstraint.get_translation_limits_max() | SixDOF {x, y, z}, translation in m / rotation in °. Composes individual getters; error components can be 0. |
| JoltConstraint.get_translation_limits_min | JoltConstraint.get_translation_limits_min() | SixDOF {x, y, z}, translation in m / rotation in °. Composes individual getters; error components can be 0. |
| JoltConstraint.set_limit | JoltConstraint.set_limit(angle) | Cone only: half-angle 0..180°; setter Boolean, getter number in degrees or 0 on error. |
| JoltConstraint.set_limits | JoltConstraint.set_limits(minimum, maximum, twist_min = undefined, twist_max = undefined) | Boolean. Hinge: -180 ≤ min ≤ 0 ≤ max ≤ 180 degrees. Distance: 0 ≤ min ≤ max m. Slider: min ≤ 0 ≤ max m. SwingTwist: all 4 arguments required, normal/plane half-angles 0..180°, -180 ≤ twist_min ≤ twist_max ≤ 180°. Finite values; other joint types rejected. |
| JoltConstraint.set_rotation_limits | JoltConstraint.set_rotation_limits(min_x,min_y,min_z,max_x,max_y,max_z) | SixDOF: three min/max pairs, m or ° according to the name. Boolean; calls three set_axis_limit operations sequentially, not atomically — earlier axes may change before a later axis fails. |
| JoltConstraint.set_translation_limits | JoltConstraint.set_translation_limits(min_x,min_y,min_z,max_x,max_y,max_z) | SixDOF: three min/max pairs, m or ° according to the name. Boolean; calls three set_axis_limit operations sequentially, not atomically — earlier axes may change before a later axis fails. |