Skip to main content

MateKind

Enum MateKind 

Source
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).

Fields

§point_a: [f64; 3]
§point_b: [f64; 3]
§

CoincidentPointPlane

A point of body A lies on a plane of body B (1 DOF removed).

Fields

§point_a: [f64; 3]
§plane_b: MatePlane
§

CoincidentPlanePlane

Two planes are coplanar with the given normal sense (3 DOF removed).

Fields

§plane_a: MatePlane
§plane_b: MatePlane
§

ConcentricAxisAxis

Two axes are collinear (4 DOF removed; spin + slide stay free).

Fields

§axis_a: MateAxis
§axis_b: MateAxis
§

DistancePointPoint

‖pa − pb‖ equals distance (1 DOF removed). A zero distance degrades gracefully to a point-point coincidence.

Fields

§point_a: [f64; 3]
§point_b: [f64; 3]
§distance: f64
§

DistancePointPlane

Signed height of the point above the plane (along its world normal) equals distance (1 DOF removed).

Fields

§point_a: [f64; 3]
§plane_b: MatePlane
§distance: f64
§

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).

Fields

§plane_a: MatePlane
§plane_b: MatePlane
§distance: f64
§

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).

Fields

§point_a: [f64; 3]
§axis_b: MateAxis
§distance: f64
§

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.

Fields

§axis_a: MateAxis
§axis_b: MateAxis
§distance: f64
§

Angle

Angle in degrees between two world directions (plane normals or axis directions); residual is cos(measured) − cos(target) (1 DOF removed).

Fields

§direction_a: [f64; 3]
§direction_b: [f64; 3]
§angle_deg: f64
§

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.

Fields

§direction_a: [f64; 3]
§direction_b: [f64; 3]
§axis_a: [f64; 3]
§angle_deg: f64
§

Parallel

Directions parallel (2 DOF removed).

Fields

§direction_a: [f64; 3]
§direction_b: [f64; 3]
§

Perpendicular

Directions perpendicular (1 DOF removed).

Fields

§direction_a: [f64; 3]
§direction_b: [f64; 3]
§

TangentSpherePlane

Sphere (centre on body A, radius) tangent to a plane of body B, centre on the positive-normal side (1 DOF removed).

Fields

§center_a: [f64; 3]
§radius: f64
§plane_b: MatePlane
§

TangentCylinderPlane

Cylinder (axis on body A, radius) tangent to a plane of body B, axis on the positive-normal side (2 DOF removed).

Fields

§axis_a: MateAxis
§radius: f64
§plane_b: MatePlane
§

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.

Fields

§min: f64
§max: f64
§

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).

Fields

§point_a: [f64; 3]
§curve_b: MateCurve
§along: Option<f64>
§reverse: bool
§

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.

Fields

§axis_a: MateAxis
§curve_b: MateCurve
§normal_b: [f64; 3]
§along: Option<f64>
§reverse: bool
§

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

§center_a: [f64; 3]
§axis_a: Option<[f64; 3]>
§radius: f64
§profile_b: MateCurve
§normal_b: [f64; 3]
§flip: bool
§

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.

Fields

§plane_c: MatePlane
§

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

§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

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

§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

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).

Fields

§axis_a: MateAxis
§ref_a: [f64; 3]
§ref_b: [f64; 3]
§point_b: [f64; 3]
§pitch: f64
§reverse: bool
§angle0: f64
§offset0: f64

Implementations§

Source§

impl MateKind

Source

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.

Source

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.

Source

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.

Source

pub fn rebase( &mut self, pose_a: ([f64; 4], [f64; 3]), pose_b: ([f64; 4], [f64; 3]), )

Trait Implementations§

Source§

impl Clone for MateKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MateKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for MateKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MateKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more