Class PointOnLine
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Keeps an anchor on body 2 on a line attached to body 1, with optional limits along the line. Relative rotation remains free.
public class PointOnLine : Constraint<PointOnLine.PointOnLineData>, IDebugDrawable
- Inheritance
-
PointOnLine
- Implements
- Inherited Members
Properties
Bias
Gets or sets the bias factor controlling how aggressively positional error is corrected.
public float Bias { get; set; }
Property Value
- float
Default is DefaultLinearBias. Higher values correct errors faster but may cause instability.
Distance
Gets the current distance of the anchor point from the line origin along the axis.
public float Distance { get; }
Property Value
Impulse
Gets the accumulated solver impulse from the last solved substep.
public JVector Impulse { get; }
Property Value
LimitBias
Gets or sets the bias factor for distance limit correction.
public float LimitBias { get; set; }
Property Value
- float
Default is 0.2. Higher values correct limit violations faster.
LimitSoftness
Gets or sets the softness (compliance) applied when distance limits are active.
public float LimitSoftness { get; set; }
Property Value
- float
Default is 0.0001. Higher values allow more limit violation but improve stability.
Softness
Gets or sets the softness (compliance) of the constraint.
public float Softness { get; set; }
Property Value
- float
Default is 0.00001. Higher values allow more positional 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
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(JVector, JVector, JVector)
Initializes the constraint from world-space parameters.
public void Initialize(JVector axis, JVector anchor1, JVector anchor2)
Parameters
axisJVectorThe line axis in world space, fixed in the reference frame of body 1.
anchor1JVectorAnchor point on body 1 defining the line origin in world space.
anchor2JVectorAnchor point on body 2 constrained to the line in world space.
Remarks
Equal or reversed distance limits fix the point at their midpoint. Default values: Bias = DefaultLinearBias, Softness = DefaultLinearSoftness, LimitSoftness = DefaultLinearLimitSoftness, LimitBias = DefaultLinearLimitBias.
Exceptions
- ArgumentException
Thrown when
axisis zero or contains a non-finite value, whenanchor1oranchor2contains a non-finite value, or when either value inlimitis NaN.
Initialize(JVector, JVector, JVector, LinearLimit)
Initializes the constraint from world-space parameters.
public void Initialize(JVector axis, JVector anchor1, JVector anchor2, LinearLimit limit)
Parameters
axisJVectorThe line axis in world space, fixed in the reference frame of body 1.
anchor1JVectorAnchor point on body 1 defining the line origin in world space.
anchor2JVectorAnchor point on body 2 constrained to the line in world space.
limitLinearLimitDistance limit along the axis.
Remarks
Equal or reversed distance limits fix the point at their midpoint. Default values: Bias = DefaultLinearBias, Softness = DefaultLinearSoftness, LimitSoftness = DefaultLinearLimitSoftness, LimitBias = DefaultLinearLimitBias.
Exceptions
- ArgumentException
Thrown when
axisis zero or contains a non-finite value, whenanchor1oranchor2contains a non-finite value, or when either value inlimitis NaN.
IteratePointOnLine(ref ConstraintData, in TimeStep)
public static void IteratePointOnLine(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationPointOnLine(ref ConstraintData, in TimeStep)
public static void PrepareForIterationPointOnLine(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()