@box2d/debug-draw
Version:
Debug drawing helper for @box2d
132 lines • 4.9 kB
TypeScript
import { b2Vec2, XY } from "../common/b2_math";
import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint";
import { b2SolverData } from "./b2_time_step";
import type { b2Body } from "./b2_body";
import { b2Draw } from "../common/b2_draw";
import { b2Readonly } from "../common/b2_readonly";
export interface b2IDistanceJointDef extends b2IJointDef {
localAnchorA: XY;
localAnchorB: XY;
length: number;
minLength: number;
maxLength: number;
stiffness?: number;
damping?: number;
}
/**
* Distance joint definition. This requires defining an anchor point on both
* bodies and the non-zero distance of the distance joint. The definition uses
* local anchor points so that the initial configuration can violate the
* constraint slightly. This helps when saving and loading a game.
*/
export declare class b2DistanceJointDef extends b2JointDef implements b2IDistanceJointDef {
/** The local anchor point relative to bodyA's origin. */
readonly localAnchorA: b2Vec2;
/** The local anchor point relative to bodyB's origin. */
readonly localAnchorB: b2Vec2;
/** The rest length of this joint. Clamped to a stable minimum value. */
length: number;
/** Minimum length. Clamped to a stable minimum value. */
minLength: number;
/** Maximum length. Must be greater than or equal to the minimum length. */
maxLength: number;
/** The linear stiffness in N/m. */
stiffness: number;
/** The linear damping in N*s/m. */
damping: number;
constructor();
/**
* Initialize the bodies, anchors, and rest length using world space anchors.
* The minimum and maximum lengths are set to the rest length.
*/
Initialize(b1: b2Body, b2: b2Body, anchor1: XY, anchor2: XY): void;
}
/**
* A distance joint constrains two points on two bodies to remain at a fixed
* distance from each other. You can view this as a massless, rigid rod.
*/
export declare class b2DistanceJoint extends b2Joint {
protected m_stiffness: number;
protected m_damping: number;
protected m_bias: number;
protected m_length: number;
protected m_minLength: number;
protected m_maxLength: number;
protected readonly m_localAnchorA: b2Vec2;
protected readonly m_localAnchorB: b2Vec2;
protected m_gamma: number;
protected m_impulse: number;
protected m_lowerImpulse: number;
protected m_upperImpulse: number;
protected m_indexA: number;
protected m_indexB: number;
protected readonly m_u: b2Vec2;
protected readonly m_rA: b2Vec2;
protected readonly m_rB: b2Vec2;
protected readonly m_localCenterA: b2Vec2;
protected readonly m_localCenterB: b2Vec2;
protected m_currentLength: number;
protected m_invMassA: number;
protected m_invMassB: number;
protected m_invIA: number;
protected m_invIB: number;
protected m_softMass: number;
protected m_mass: number;
/** @internal protected */
constructor(def: b2IDistanceJointDef);
GetAnchorA<T extends XY>(out: T): T;
GetAnchorB<T extends XY>(out: T): T;
/**
* Get the reaction force given the inverse time step.
* Unit is N.
*/
GetReactionForce<T extends XY>(inv_dt: number, out: T): T;
/**
* Get the reaction torque given the inverse time step.
* Unit is N*m. This is always zero for a distance joint.
*/
GetReactionTorque(_inv_dt: number): number;
/** The local anchor point relative to bodyA's origin. */
GetLocalAnchorA(): b2Readonly<b2Vec2>;
/** The local anchor point relative to bodyB's origin. */
GetLocalAnchorB(): b2Readonly<b2Vec2>;
/**
* Set the rest length
* @returns clamped rest length
*/
SetLength(length: number): number;
/** Get the rest length */
GetLength(): number;
/**
* Set the minimum length
* @returns the clamped minimum length
*/
SetMinLength(minLength: number): number;
/** Get the minimum length */
GetMinLength(): number;
/**
* Set the maximum length
* @returns the clamped maximum length
*/
SetMaxLength(maxLength: number): number;
/** Get the maximum length */
GetMaxLength(): number;
/** Get the current length */
GetCurrentLength(): number;
/** Set the linear stiffness in N/m */
SetStiffness(stiffness: number): void;
/** Get the linear stiffness in N/m */
GetStiffness(): number;
/** Set linear damping in N*s/m */
SetDamping(damping: number): void;
/** Get linear damping in N*s/m */
GetDamping(): number;
/** @internal protected */
InitVelocityConstraints(data: b2SolverData): void;
/** @internal protected */
SolveVelocityConstraints(data: b2SolverData): void;
/** @internal protected */
SolvePositionConstraints(data: b2SolverData): boolean;
Draw(draw: b2Draw): void;
}
//# sourceMappingURL=b2_distance_joint.d.ts.map