# Struct nphysics3d::force_generator::Spring [−][src]

pub struct Spring<N: Real> { /* fields omitted */ }

Generator of a force proportional to the distance separating two bodies.

## Methods

`impl<N: Real> Spring<N>`

[src]

`impl<N: Real> Spring<N>`

`pub fn new(`

b1: BodyHandle,

b2: BodyHandle,

anchor1: Point<N>,

anchor2: Point<N>,

length: N,

stiffness: N

) -> Self

[src]

`pub fn new(`

b1: BodyHandle,

b2: BodyHandle,

anchor1: Point<N>,

anchor2: Point<N>,

length: N,

stiffness: N

) -> Self

Initialize a spring attached to `b1`

and `b2`

at the points `anchor1`

and `anchor2`

.

Anchors are expressed in the local coordinates of the corresponding bodies.
The spring has a rest length of `length`

and a stiffness of `stiffness`

.

`pub fn set_anchor_1(&mut self, anchor: Point<N>)`

[src]

`pub fn set_anchor_1(&mut self, anchor: Point<N>)`

Sets the attach point to the first body.

The anchor is expressed in the local coordinatse of the first body.

`pub fn set_anchor_2(&mut self, anchor: Point<N>)`

[src]

`pub fn set_anchor_2(&mut self, anchor: Point<N>)`

Sets the attach point to the second body.

The anchor is expressed in the local coordinatse of the second body.

## Trait Implementations

`impl<N: Real> ForceGenerator<N> for Spring<N>`

[src]

`impl<N: Real> ForceGenerator<N> for Spring<N>`

`fn apply(`

&mut self,

_: &IntegrationParameters<N>,

bodies: &mut BodySet<N>

) -> bool

[src]

`fn apply(`

&mut self,

_: &IntegrationParameters<N>,

bodies: &mut BodySet<N>

) -> bool

Apply forces to some bodies.