pub enum MateKind {
Show 23 variants
CoincidentPointPoint {
point_a: [f64; 3],
point_b: [f64; 3],
},
CoincidentPointPlane {
point_a: [f64; 3],
plane_b: MatePlane,
},
CoincidentPlanePlane {
plane_a: MatePlane,
plane_b: MatePlane,
align: MateAlign,
},
ConcentricAxisAxis {
axis_a: MateAxis,
axis_b: MateAxis,
align: MateAlign,
},
DistancePointPoint {
point_a: [f64; 3],
point_b: [f64; 3],
distance: f64,
},
DistancePointPlane {
point_a: [f64; 3],
plane_b: MatePlane,
distance: f64,
},
DistancePlanePlane {
plane_a: MatePlane,
plane_b: MatePlane,
distance: f64,
align: MateAlign,
},
DistancePointLine {
point_a: [f64; 3],
axis_b: MateAxis,
distance: f64,
},
DistanceLineLine {
axis_a: MateAxis,
axis_b: MateAxis,
distance: f64,
},
Angle {
direction_a: [f64; 3],
direction_b: [f64; 3],
angle_deg: f64,
},
DirectedAngle {
direction_a: [f64; 3],
direction_b: [f64; 3],
axis_a: [f64; 3],
angle_deg: f64,
},
Parallel {
direction_a: [f64; 3],
direction_b: [f64; 3],
align: MateAlign,
},
Perpendicular {
direction_a: [f64; 3],
direction_b: [f64; 3],
},
TangentSpherePlane {
center_a: [f64; 3],
radius: f64,
plane_b: MatePlane,
},
TangentCylinderPlane {
axis_a: MateAxis,
radius: f64,
plane_b: MatePlane,
},
Limit {
mate: Box<MateKind>,
min: f64,
max: f64,
},
PointOnCurve {
point_a: [f64; 3],
curve_b: MateCurve,
along: Option<f64>,
reverse: bool,
},
Slot {
axis_a: MateAxis,
curve_b: MateCurve,
normal_b: [f64; 3],
along: Option<f64>,
reverse: bool,
},
Cam {
center_a: [f64; 3],
axis_a: Option<[f64; 3]>,
radius: f64,
profile_b: MateCurve,
normal_b: [f64; 3],
flip: bool,
},
Symmetric {
element_a: SymmetricElement,
element_b: SymmetricElement,
plane_c: MatePlane,
},
Gear {
axis_a: MateAxis,
ref_a: [f64; 3],
world_ref_a: [f64; 3],
axis_b: MateAxis,
ref_b: [f64; 3],
world_ref_b: [f64; 3],
ratio: f64,
reverse: bool,
},
RackPinion {
pinion_axis: MateAxis,
pinion_ref: [f64; 3],
world_pinion_ref: [f64; 3],
rack_point: [f64; 3],
rack_direction: [f64; 3],
world_rack_point: [f64; 3],
distance_per_revolution: f64,
reverse: bool,
},
Screw {
axis_a: MateAxis,
ref_a: [f64; 3],
ref_b: [f64; 3],
point_b: [f64; 3],
pitch: f64,
reverse: bool,
angle0: f64,
offset0: f64,
},
}Expand description
Mate geometry + semantics. All points/directions/planes/axes are expressed
in the OWNING body’s local frame (*_a on body_a, *_b on body_b).
Variants§
CoincidentPointPoint
Two local points touch (3 DOF removed).
CoincidentPointPlane
A point of body A lies on a plane of body B (1 DOF removed).
CoincidentPlanePlane
Two planes are coplanar with the given normal sense (3 DOF removed).
ConcentricAxisAxis
Two axes are collinear (4 DOF removed; spin + slide stay free).
DistancePointPoint
‖pa − pb‖ equals distance (1 DOF removed). A zero distance degrades
gracefully to a point-point coincidence.
DistancePointPlane
Signed height of the point above the plane (along its world normal)
equals distance (1 DOF removed).
DistancePlanePlane
Parallel planes at a signed offset: distance is measured from plane
A to plane B’s origin along plane A’s world normal (3 DOF removed).
DistancePointLine
Distance from a point of body A to an INFINITE line of body B equals
distance (1 DOF removed): residual ‖(p − o) ⊥ d‖ − distance. A
zero distance degrades gracefully to point-on-line coincidence (the
coincident_point_line shortcut — the norm residual would be
non-differentiable at zero).
DistanceLineLine
Closest-approach distance between two INFINITE lines equals distance
(1 DOF removed). Skew lines use |u·(da×db)|/‖da×db‖; nearly parallel
lines (sine of the angle below ASM_LL_SIN_PARALLEL) are measured
point-to-line instead — the skew formula degenerates there — with a C1
smoothstep blend of the squared measures across the band up to
ASM_LL_SIN_SKEW. A zero distance degrades to a signed touch
constraint (intersecting when skew, collinear when parallel), so
parallel + distance_line_line(0) is the concentric shortcut
without the direction rows.
Angle
Angle in degrees between two world directions (plane normals or axis
directions); residual is cos(measured) − cos(target) (1 DOF removed).
DirectedAngle
Signed angle from A to B about axis_a (in body A’s local frame).
Measures B’s projection into the plane perpendicular to the axis.
The wrapped angular residual removes one DOF and retains the rotation
sense at negative/reflex targets and through parallel configurations.
Parallel
Directions parallel (2 DOF removed).
Perpendicular
Directions perpendicular (1 DOF removed).
TangentSpherePlane
Sphere (centre on body A, radius) tangent to a plane of body B, centre on the positive-normal side (1 DOF removed).
TangentCylinderPlane
Cylinder (axis on body A, radius) tangent to a plane of body B, axis on the positive-normal side (2 DOF removed).
Limit
A LIMIT mate: the quantity mate measures stays inside [min, max]
instead of equalling its target (whose own value is ignored). mate
is a distance kind (min/max in model units, signed exactly as that
kind’s distance) or an angle kind (degrees; DirectedAngle is
signed, wraps, and the range runs from min counter-clockwise to
max). The rows the kind holds besides its measure (the parallelism of
DistancePlanePlane) still bind. Inside the range the limit row is
zero and removes nothing; outside it is the signed distance to the
nearer end.
PointOnCurve
Path: point_a lies on curve_b (3 rows, removes 2 DOF) — the closest
point of the curve, found afresh from fixed samples at every evaluation
(no state between evaluations). along, when set, also pins where on
the curve: a percent of its parameter range from its start (from its
end with reverse), wrapped on a closed curve (1 row more).
Slot
Slot: the axis axis_a stays parallel to normal_b (either sense)
and passes through curve_b, the slot’s centreline (3 + 3 rows,
removes 4 DOF; the pin may slide along the curve, between its ends,
spin, and slide along its own axis). along / reverse as for
MateKind::PointOnCurve, read where the axis crosses the curve.
Cam
Cam: a follower of radius radius centred at center_a (a roller
when axis_a is set: its axis stays parallel to normal_b; else a
ball or point, kept in the profile’s plane) touches profile_b, a
planar curve with plane normal normal_b: the follower’s in-plane
distance to the profile equals its radius, on the outside of a closed
profile (the left of an open one, seen from the normal) unless
flip (1 row + the plane rows).
Fields
Symmetric
element_a (on body A) and element_b (on body B) are mirror images
about plane_c, a plane of the mate’s body_c: points mirror onto
points (3 DOF), a plane onto a plane facing the mirrored way (3 DOF),
an axis onto an axis in either sense (4 DOF). Both elements must be of
one kind.
Gear
Gear: A’s spin about axis_a and B’s spin about axis_b are coupled,
ratio·θa + θb = 0 (external mesh, opposite senses; reverse makes it
ratio·θa − θb = 0). A spin is the signed angle, about the body’s own
axis, from the WORLD reference world_ref_* to the body’s local
ref_* (a direction ⟂ its axis). ratio is teeth(A)/teeth(B) — B’s
turns per turn of A. MateKind::rebase captures the references so the
mate holds the poses it is given (1 DOF removed).
Fields
RackPinion
Rack and pinion: pinion A’s spin about pinion_axis (measured as for
Gear) drives rack B along its local rack_direction: the travel of
rack_point from world_rack_point along that direction equals
distance_per_revolution · θ / 2π (reverse flips the sense) (1 DOF).
Fields
Screw
Screw: B advances along A’s axis_a by pitch per turn it makes
about it, relative to A: (s − offset0) = ±pitch·(θ − angle0)/2π,
where θ is the signed angle about the axis from A’s ref_a to B’s
ref_b and s the height of B’s point_b along the axis (1 DOF).
Implementations§
Source§impl MateKind
impl MateKind
Sourcepub fn references(&self) -> Option<Vec<f64>>
pub fn references(&self) -> Option<Vec<f64>>
Re-capture a mechanical mate’s references so it holds exactly the
poses given ((rotation [w,x,y,z], translation) of body A and body B):
the gear’s and the pinion’s world reference directions, the rack’s
world point, the screw’s angle and offset. Every other kind is left
alone. Mapping calls this at the current poses, so a new mate moves
nothing; a live drag calls it at the last good poses, so each frame
couples only the motion since then and never wraps a spin.
A mechanical mate’s captured references as plain numbers (the world
reference directions / point, or the screw’s angle and offset), for
persisting across runs; None for every other kind.
Sourcepub fn set_references(&mut self, values: &[f64]) -> bool
pub fn set_references(&mut self, values: &[f64]) -> bool
Restore references saved by MateKind::references; false (and no
change) when the kind or the count does not match.
Sourcepub fn driver(
&self,
pose_a: ([f64; 4], [f64; 3]),
pose_b: ([f64; 4], [f64; 3]),
) -> Option<bool>
pub fn driver( &self, pose_a: ([f64; 4], [f64; 3]), pose_b: ([f64; 4], [f64; 3]), ) -> Option<bool>
Which side of a gear or rack-and-pinion moved since its references
were captured, when exactly one did: Some(true) for body A, Some(false)
for body B. A typed edit of one gear makes that gear the driver.