nphysics2d/joint/
joint_motor.rs1use crate::solver::ImpulseLimits;
2use na::RealField;
3use num::Zero;
4
5#[derive(Copy, Clone, Debug)]
7pub struct JointMotor<V, N: RealField + Copy> {
8 pub desired_velocity: V,
10 pub max_velocity: N,
12 pub max_force: N,
14 pub enabled: bool,
16}
17
18impl<V: Zero, N: RealField + Copy> JointMotor<V, N> {
19 pub fn new() -> Self {
23 JointMotor {
24 desired_velocity: V::zero(),
25 max_velocity: N::max_value(),
26 max_force: N::max_value(),
27 enabled: false,
28 }
29 }
30
31 pub fn impulse_limits(&self) -> ImpulseLimits<N> {
33 ImpulseLimits::Independent {
34 min: -self.max_force,
35 max: self.max_force,
36 }
37 }
38}
39
40impl<V: Zero, N: RealField + Copy> Default for JointMotor<V, N> {
41 fn default() -> Self {
42 Self::new()
43 }
44}