Class AngularMotor
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Represents a motor that drives relative angular velocity between two axes fixed in the reference frames of their respective bodies.
public class AngularMotor : Constraint<AngularMotor.AngularMotorData>, IDebugDrawable
- Inheritance
-
AngularMotor
- Implements
- Inherited Members
Properties
LocalAxis1
Gets the motor axis on the first body in local space.
public JVector LocalAxis1 { get; }
Property Value
LocalAxis2
Gets the motor axis on the second body in local space.
public JVector LocalAxis2 { get; }
Property Value
MaximumForce
Gets or sets the maximum force the motor can apply.
public float MaximumForce { get; set; }
Property Value
- float
Default is 0. Must be non-negative.
Exceptions
- ArgumentOutOfRangeException
Thrown when
valueis negative.
TargetVelocity
Gets or sets the target angular velocity in radians per second.
public float TargetVelocity { get; set; }
Property Value
- float
Default is 0.
Methods
Create()
Sets the solver dispatch id used by this instance. Override this in derived classes to assign the correct registered solver pair. The id is later written into the unmanaged header when the constraint is enabled.
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.
Initialize(JVector)
Initializes the motor with the same axis for both bodies.
public void Initialize(JVector axis)
Parameters
axisJVectorThe motor axis in world space, used for both bodies.
Exceptions
- ArgumentException
Thrown when
axisis zero or contains a non-finite value.
Initialize(JVector, JVector)
Initializes the motor with separate axes for each body.
public void Initialize(JVector axis1, JVector axis2)
Parameters
axis1JVectorThe motor axis on the first body in world space.
axis2JVectorThe motor axis on the second body in world space.
Remarks
Stores the axes in local frames. Both axes are normalized internally. Default values: TargetVelocity = 0, MaximumForce = 0.
Exceptions
- ArgumentException
Thrown when
axis1oraxis2is zero or contains a non-finite value.
IterateAngularMotor(ref ConstraintData, float)
public static void IterateAngularMotor(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat
PrepareForIterationAngularMotor(ref ConstraintData, float)
public static void PrepareForIterationAngularMotor(ref ConstraintData constraint, float idt)
Parameters
constraintConstraintDataidtfloat
ResetWarmStart()
Resets the cached warm-start state used by the solver for this constraint.
public override void ResetWarmStart()
Remarks
This clears only persistent solver impulses. Constraint configuration remains unchanged. Useful after restoring snapshots or other discontinuous state changes where preserving warm-starting is undesirable.