Class EllipticalConeLimit
- Namespace
- Jitter2.Dynamics.Constraints
- Assembly
- Jitter2.dll
Restricts relative swing to the region between two elliptical cones, leaving twist free.
public class EllipticalConeLimit : Constraint<EllipticalConeLimit.EllipticalConeLimitData>, IDebugDrawable
- Inheritance
-
EllipticalConeLimit
- Implements
- Inherited Members
Remarks
Body 1 owns the cone frame; body 2 owns the axis being constrained. The boundaries are ellipses in swing-angle coordinates (the shortest tilt, resolved along the two frame directions). Equal lower and upper boundaries constrain the axis to the cone surface. Identical ranges in both directions reproduce a circular cone. This constraint does not restrict translation.
Properties
AxisBody1
Gets body 1's central cone axis in world space.
public JVector AxisBody1 { get; }
Property Value
AxisBody2
Gets body 2's constrained axis in world space.
public JVector AxisBody2 { get; }
Property Value
Bias
Gets or sets the angular error correction factor. Default is 0.2.
public float Bias { get; set; }
Property Value
Impulse
Gets the accumulated solver impulse from the last solved substep.
public float Impulse { get; }
Property Value
LimitAlongPerpendicular
Gets the inner and outer angular semiaxes in the perpendicular direction.
public AngularLimit LimitAlongPerpendicular { get; }
Property Value
LimitAlongReference
Gets the inner and outer angular semiaxes in the reference direction.
public AngularLimit LimitAlongReference { get; }
Property Value
ReferenceDirectionBody1
Gets the first ellipse direction in world space, perpendicular to AxisBody1.
public JVector ReferenceDirectionBody1 { get; }
Property Value
Softness
Gets or sets the softness (compliance). Default is 0.001.
public float Softness { get; set; }
Property Value
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.
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
GetSwing(out JAngle, out JAngle)
Gets signed swing-angle coordinates along the reference and perpendicular directions. Their Euclidean length is the tilt angle. At exactly opposite axes the swing direction is ambiguous.
public void GetSwing(out JAngle alongReference, out JAngle alongPerpendicular)
Parameters
Initialize(JVector, JVector, AngularLimit, AngularLimit)
Initializes both body axes from the same world-space direction.
public void Initialize(JVector axis, JVector referenceDirection, AngularLimit limitAlongReference, AngularLimit limitAlongPerpendicular)
Parameters
axisJVectorreferenceDirectionJVectorlimitAlongReferenceAngularLimitlimitAlongPerpendicularAngularLimit
Remarks
The reference direction defines the first ellipse semiaxis on body 1. Its component along the cone axis is discarded. The second direction is axis cross reference direction. A positive inner boundary means the initially aligned pose lies outside the allowed region. See the two-axis overload to initialize a pose with nonzero swing.
Initialize(JVector, JVector, JVector, AngularLimit, AngularLimit)
Initializes the constraint using world-space axes and a world-space reference direction on body 1.
public void Initialize(JVector axisBody1, JVector axisBody2, JVector referenceDirectionBody1, AngularLimit limitAlongReference, AngularLimit limitAlongPerpendicular)
Parameters
axisBody1JVectorThe cone's central axis, attached to body 1.
axisBody2JVectorThe axis attached to body 2 whose swing is constrained.
referenceDirectionBody1JVectorThe first ellipse direction, attached to body 1.
limitAlongReferenceAngularLimitInner and outer angular semiaxes in the reference direction.
limitAlongPerpendicularAngularLimitInner and outer angular semiaxes in the perpendicular direction.
Exceptions
- ArgumentException
A direction is invalid or the reference is parallel to the cone axis.
- ArgumentOutOfRangeException
The limits do not satisfy SetLimits(AngularLimit, AngularLimit).
IterateEllipticalConeLimit(ref ConstraintData, in TimeStep)
public static void IterateEllipticalConeLimit(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
PrepareForIterationEllipticalConeLimit(ref ConstraintData, in TimeStep)
public static void PrepareForIterationEllipticalConeLimit(ref ConstraintData constraint, in TimeStep timeStep)
Parameters
constraintConstraintDatatimeStepTimeStep
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.
SetLimits(AngularLimit, AngularLimit)
Sets both angular ranges together and clears the cached impulse.
public void SetLimits(AngularLimit limitAlongReference, AngularLimit limitAlongPerpendicular)
Parameters
limitAlongReferenceAngularLimitlimitAlongPerpendicularAngularLimit
Remarks
Each range must satisfy 0 <= From <= To < pi, with To strictly positive. The lower bounds must either both be zero (no inner boundary) or both be positive. Equal bounds in both ranges define a fixed elliptical cone surface. Fixed zero or pi tilt is unsupported; use HingeAngle with AngularLimit.Full instead.
Exceptions
- ArgumentOutOfRangeException
The ranges violate the requirements above.