Table of Contents

Class LinearAxisServo

Namespace
Jitter2.Dynamics.Constraints
Assembly
Jitter2.dll

Drives the signed separation of two anchors along an axis attached to body 1 using limited force. Controls one translational degree of freedom; perpendicular movement and rotation remain free.

public class LinearAxisServo : Constraint<LinearAxisServo.LinearAxisServoData>, IDebugDrawable
Inheritance
LinearAxisServo
Implements
Inherited Members

Properties

Anchor1

Gets or sets the world-space anchor attached to body 1.

[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor1 { get; set; }

Property Value

JVector

Anchor2

Gets or sets the world-space anchor attached to body 2.

[ReferenceFrame(ReferenceFrame.World)]
public JVector Anchor2 { get; set; }

Property Value

JVector

Axis

Gets or sets the world-space direction attached to body 1, normalized internally.

[ReferenceFrame(ReferenceFrame.World)]
public JVector Axis { get; set; }

Property Value

JVector

Bias

Gets or sets how aggressively the servo corrects its position error.

public float Bias { get; set; }

Property Value

float

Default is DefaultLinearBias.

Impulse

Gets the signed impulse applied along the axis to body 2 in the last solved substep.

public float Impulse { get; }

Property Value

float

MaximumForce

Gets or sets the maximum total force the servo can apply.

public float MaximumForce { get; set; }

Property Value

float

Default is zero. Positive infinity allows unlimited force.

Position

Gets the current signed separation of the anchors along the axis.

public float Position { get; }

Property Value

float

Softness

Gets or sets the softness (compliance) of the servo.

public float Softness { get; set; }

Property Value

float

Default is DefaultLinearSoftness.

TargetPosition

Gets or sets the desired signed separation along the axis. Default is zero.

public float TargetPosition { get; set; }

Property Value

float

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

drawer IDebugDrawer

The 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

drawer IDebugDrawer
settings DebugDrawSettings

Initialize(JVector, JVector, JVector, float)

Initializes world-space anchors and an axis attached to body 1.

public void Initialize(JVector axis, JVector anchor1, JVector anchor2, float targetPosition = 0)

Parameters

axis JVector

The direction along which the servo acts, normalized internally.

anchor1 JVector

The origin attached to body 1.

anchor2 JVector

The anchor attached to body 2.

targetPosition float

The desired signed separation along the axis.

Remarks

Maximum force defaults to zero. The current separation may differ from the target.

IterateLinearAxisServo(ref ConstraintData, in TimeStep)

public static void IterateLinearAxisServo(ref ConstraintData constraint, in TimeStep timeStep)

Parameters

constraint ConstraintData
timeStep TimeStep

PrepareForIterationLinearAxisServo(ref ConstraintData, in TimeStep)

public static void PrepareForIterationLinearAxisServo(ref ConstraintData constraint, in TimeStep timeStep)

Parameters

constraint ConstraintData
timeStep TimeStep

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()

Returns

string