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
The cone is attached to body 1 and limits the tilt of an axis attached to body 2. The two angular ranges set the inner and outer tilt limits in perpendicular directions. Matching ranges produce a circular cone; matching inner and outer limits keep the axis on the cone surface. Translation remains free.
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()
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
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 sets one direction of the ellipse on body 1; it is projected perpendicular to the cone axis. The other direction is perpendicular to both. 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()
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.
SetLimits(AngularLimit, AngularLimit)
Sets the inner and outer tilt limits in both perpendicular directions.
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.
ToString()
Returns a short description of the constraint's ID, connected bodies, and state.
public override string ToString()