Table of Contents

Class HingeAngle

Namespace
Jitter2.Dynamics.Constraints
Assembly
Jitter2.dll

Allows relative rotation around a single axis, with optional angular limits. Does not keep the bodies at a shared anchor; use HingeJoint for a complete hinge.

public class HingeAngle : Constraint<HingeAngle.HingeAngleData>, IDebugDrawable
Inheritance
HingeAngle
Implements
Inherited Members

Properties

Angle

Gets the current angle of rotation around the hinge axis relative to the initial pose.

public JAngle Angle { get; }

Property Value

JAngle

Remarks

When the hinge axes are misaligned, this is the projection of the shortest relative rotation vector onto the hinge axis, matching the limit coordinate.

Bias

Gets or sets the bias factor controlling how aggressively angular error is corrected.

public float Bias { get; set; }

Property Value

float

Default is 0.2. Higher values correct errors faster but may cause instability.

Impulse

Gets the accumulated solver impulse from the last solved substep.

public JVector Impulse { get; }

Property Value

JVector

Limit

Sets the angular limits for the hinge rotation.

public AngularLimit Limit { set; }

Property Value

AngularLimit

Exceptions

ArgumentException

Thrown when either assigned limit value is not finite.

LimitBias

Gets or sets the bias factor for angular limit correction.

public float LimitBias { get; set; }

Property Value

float

Default is 0.1. Higher values correct limit violations faster.

LimitSoftness

Gets or sets the softness (compliance) applied when angular limits are active.

public float LimitSoftness { get; set; }

Property Value

float

Default is 0.001. Higher values allow more limit violation but improve stability.

Softness

Gets or sets the softness (compliance) of the angular constraint.

public float Softness { get; set; }

Property Value

float

Default is 0.001. Higher values allow more angular error but improve stability.

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, AngularLimit)

Initializes the constraint with a rotation axis and angular limits.

public void Initialize(JVector axis, AngularLimit limit)

Parameters

axis JVector

The hinge axis in world space around which rotation is allowed.

limit AngularLimit

The angular limits defining the allowed rotation range.

Remarks

The axis rotates with body 2. The initial relative orientation defines zero rotation. Equal or reversed limits fix the hinge at their midpoint. Default values: Softness = DefaultAngularSoftness, LimitSoftness = DefaultAngularLimitSoftness, Bias = DefaultAngularBias, LimitBias = DefaultAngularLimitBias.

Exceptions

ArgumentException

Thrown when axis is zero or contains a non-finite value, or when either value in limit is not finite.

IterateHingeAngle(ref ConstraintData, in TimeStep)

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

Parameters

constraint ConstraintData
timeStep TimeStep

PrepareForIterationHingeAngle(ref ConstraintData, in TimeStep)

public static void PrepareForIterationHingeAngle(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