avian2d::dynamics::solver::joints

Trait Joint

Source
pub trait Joint:
    Component
    + PositionConstraint
    + AngularConstraint {
    // Required methods
    fn new(entity1: Entity, entity2: Entity) -> Self;
    fn with_compliance(self, compliance: Scalar) -> Self;
    fn with_local_anchor_1(self, anchor: Vector) -> Self;
    fn with_local_anchor_2(self, anchor: Vector) -> Self;
    fn with_linear_velocity_damping(self, damping: Scalar) -> Self;
    fn with_angular_velocity_damping(self, damping: Scalar) -> Self;
    fn local_anchor_1(&self) -> Vector;
    fn local_anchor_2(&self) -> Vector;
    fn damping_linear(&self) -> Scalar;
    fn damping_angular(&self) -> Scalar;

    // Provided method
    fn align_position(
        &self,
        body1: &mut RigidBodyQueryItem<'_>,
        body2: &mut RigidBodyQueryItem<'_>,
        r1: Vector,
        r2: Vector,
        lagrange: &mut Scalar,
        compliance: Scalar,
        dt: Scalar,
    ) -> Vector { ... }
}
Expand description

A trait for joints.

Required Methods§

Source

fn new(entity1: Entity, entity2: Entity) -> Self

Creates a new joint between two entities.

Source

fn with_compliance(self, compliance: Scalar) -> Self

Sets the joint’s compliance (inverse of stiffness, meters / Newton).

Source

fn with_local_anchor_1(self, anchor: Vector) -> Self

Sets the attachment point on the first body.

Source

fn with_local_anchor_2(self, anchor: Vector) -> Self

Sets the attachment point on the second body.

Source

fn with_linear_velocity_damping(self, damping: Scalar) -> Self

Sets the linear velocity damping caused by the joint.

Source

fn with_angular_velocity_damping(self, damping: Scalar) -> Self

Sets the angular velocity damping caused by the joint.

Source

fn local_anchor_1(&self) -> Vector

Returns the local attachment point on the first body.

Source

fn local_anchor_2(&self) -> Vector

Returns the local attachment point on the second body.

Source

fn damping_linear(&self) -> Scalar

Returns the linear velocity damping of the joint.

Source

fn damping_angular(&self) -> Scalar

Returns the angular velocity damping of the joint.

Provided Methods§

Source

fn align_position( &self, body1: &mut RigidBodyQueryItem<'_>, body2: &mut RigidBodyQueryItem<'_>, r1: Vector, r2: Vector, lagrange: &mut Scalar, compliance: Scalar, dt: Scalar, ) -> Vector

Applies a positional correction that aligns the positions of the local attachment points r1 and r2.

Returns the force exerted by the alignment.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§