Class AngularServo
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Drives body 2 toward a target orientation relative to body 1 using limited torque. Controls three angular degrees of freedom; translation remains free.
public class AngularServo : Constraint<AngularServo.AngularServoData>, IDebugDrawable
- Inheritance
-
AngularServo
- Implements
- Inherited Members
Properties
Bias
Gets or sets how aggressively the servo corrects its position error.
public float Bias { get; set; }
Property Value
- float
Default is DefaultAngularBias.
Impulse
Gets the world-space angular impulse applied to body 1 in the last solved substep.
public JVector Impulse { get; }
Property Value
MaximumTorque
Gets or sets the maximum total torque the servo can apply.
public float MaximumTorque { get; set; }
Property Value
- float
Default is zero. Positive infinity allows unlimited torque.
Softness
Gets or sets the softness (compliance) of the servo.
public float Softness { get; set; }
Property Value
- float
Default is DefaultAngularSoftness.
TargetRelativeOrientation
Gets or sets body 2's target orientation relative to body 1. Identity aligns their local frames. The value must be normalized. Changing it does not move either body.
public JQuaternion TargetRelativeOrientation { get; set; }
Property Value
Remarks
The servo uses the shortest rotation to the target orientation. Revolution counts are not supported.
Methods
Create()
Called when the world creates this constraint. Override to set DispatchId to the ID returned by registering the constraint's solver methods.
protected override void Create()
DebugDraw(IDebugDrawer)
Draws a debug visualization of this constraint.
public override void DebugDraw(IDebugDrawer drawer)
Parameters
drawerIDebugDrawerThe debug drawer to receive visualization primitives.
Exceptions
- NotImplementedException
Thrown if the derived class does not override this method.
DebugDraw(IDebugDrawer, in DebugDrawSettings)
Draws this constraint using the supplied visualization settings. Custom constraints that only override DebugDraw(IDebugDrawer) use their default visualization.
public override void DebugDraw(IDebugDrawer drawer, in DebugDrawSettings settings)
Parameters
drawerIDebugDrawersettingsDebugDrawSettings
Initialize()
Initializes the servo with the current relative orientation as its target.
public void Initialize()
Initialize(JQuaternion)
Initializes a target orientation for body 2 relative to body 1.
public void Initialize(JQuaternion targetRelativeOrientation)
Parameters
targetRelativeOrientationJQuaternionA normalized orientation in body 1's frame.
Remarks
The bodies may start outside the target pose. Maximum torque defaults to zero.
IterateAngularServo(ref ConstraintData, in TimeStep)
public static void IterateAngularServo(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationAngularServo(ref ConstraintData, in TimeStep)
public static void PrepareForIterationAngularServo(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
ResetWarmStart()
Clears impulses saved from the previous solve, without changing constraint settings.
public override void ResetWarmStart()
Remarks
Use after restoring a saved state or making a sudden change to the bodies, when impulses from their previous state should no longer be reused.
ToString()
Returns a short description of the constraint's ID, connected bodies, and state.
public override string ToString()