UNPKG

@box2d/debug-draw

Version:

Debug drawing helper for @box2d

150 lines 6.1 kB
import { b2Draw } from "../common/b2_draw"; import { b2Vec2, b2Mat22, XY } from "../common/b2_math"; import { b2Readonly } from "../common/b2_readonly"; import { b2Body } from "./b2_body"; import { b2Joint, b2JointDef, b2IJointDef } from "./b2_joint"; import { b2SolverData } from "./b2_time_step"; export interface b2IRevoluteJointDef extends b2IJointDef { localAnchorA?: XY; localAnchorB?: XY; referenceAngle?: number; enableLimit?: boolean; lowerAngle?: number; upperAngle?: number; enableMotor?: boolean; motorSpeed?: number; maxMotorTorque?: number; } /** * Revolute joint definition. This requires defining an anchor point where the * bodies are joined. The definition uses local anchor points so that the * initial configuration can violate the constraint slightly. You also need to * specify the initial relative angle for joint limits. This helps when saving * and loading a game. * The local anchor points are measured from the body's origin * rather than the center of mass because: * 1. you might not know where the center of mass will be. * 2. if you add/remove shapes from a body and recompute the mass, * the joints will be broken. */ export declare class b2RevoluteJointDef extends b2JointDef implements b2IRevoluteJointDef { /** 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 bodyB angle minus bodyA angle in the reference state (radians). */ referenceAngle: number; /** A flag to enable joint limits. */ enableLimit: boolean; /** The lower angle for the joint limit (radians). */ lowerAngle: number; /** The upper angle for the joint limit (radians). */ upperAngle: number; /** A flag to enable the joint motor. */ enableMotor: boolean; /** The desired motor speed. Usually in radians per second. */ motorSpeed: number; /** * The maximum motor torque used to achieve the desired motor speed. * Usually in N-m. */ maxMotorTorque: number; constructor(); /** Initialize the bodies, anchors, and reference angle using a world anchor point. */ Initialize(bA: b2Body, bB: b2Body, anchor: XY): void; } /** * A revolute joint constrains two bodies to share a common point while they * are free to rotate about the point. The relative rotation about the shared * point is the joint angle. You can limit the relative rotation with * a joint limit that specifies a lower and upper angle. You can use a motor * to drive the relative rotation about the shared point. A maximum motor torque * is provided so that infinite forces are not generated. */ export declare class b2RevoluteJoint extends b2Joint { /** @internal protected */ readonly m_localAnchorA: b2Vec2; /** @internal protected */ readonly m_localAnchorB: b2Vec2; protected readonly m_impulse: b2Vec2; protected m_motorImpulse: number; protected m_lowerImpulse: number; protected m_upperImpulse: number; protected m_enableMotor: boolean; protected m_maxMotorTorque: number; protected m_motorSpeed: number; protected m_enableLimit: boolean; /** @internal protected */ m_referenceAngle: number; protected m_lowerAngle: number; protected m_upperAngle: number; protected m_indexA: number; protected m_indexB: number; protected readonly m_rA: b2Vec2; protected readonly m_rB: b2Vec2; protected readonly m_localCenterA: b2Vec2; protected readonly m_localCenterB: b2Vec2; protected m_invMassA: number; protected m_invMassB: number; protected m_invIA: number; protected m_invIB: number; protected readonly m_K: b2Mat22; protected m_angle: number; protected m_axialMass: number; /** @internal protected */ constructor(def: b2IRevoluteJointDef); InitVelocityConstraints(data: b2SolverData): void; SolveVelocityConstraints(data: b2SolverData): void; SolvePositionConstraints(data: b2SolverData): boolean; 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 due to the joint limit given the inverse time step. * Unit is N*m. */ 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>; /** Get the reference angle. */ GetReferenceAngle(): number; /** Get the current joint angle in radians. */ GetJointAngle(): number; /** Get the current joint angle speed in radians per second. */ GetJointSpeed(): number; /** Is the joint motor enabled? */ IsMotorEnabled(): boolean; /** Enable/disable the joint motor. */ EnableMotor(flag: boolean): boolean; /** * Get the current motor torque given the inverse time step. * Unit is N*m. */ GetMotorTorque(inv_dt: number): number; /** Get the motor speed in radians per second. */ GetMotorSpeed(): number; /** Set the maximum motor torque, usually in N-m. */ SetMaxMotorTorque(torque: number): void; /** Get the maximum motor torque, usually in N-m. */ GetMaxMotorTorque(): number; /** Is the joint limit enabled? */ IsLimitEnabled(): boolean; /** Enable/disable the joint limit. */ EnableLimit(flag: boolean): boolean; /** Get the lower joint limit in radians. */ GetLowerLimit(): number; /** Get the upper joint limit in radians. */ GetUpperLimit(): number; /** Set the joint limits in radians. */ SetLimits(lower: number, upper: number): void; /** Set the motor speed in radians per second. */ SetMotorSpeed(speed: number): number; Draw(draw: b2Draw): void; } //# sourceMappingURL=b2_revolute_joint.d.ts.map