# b2DistanceJointDef Struct Reference

`#include <b2DistanceJoint.h>`

Inheritance diagram for b2DistanceJointDef:

List of all members.

## Public Member Functions
| b2DistanceJointDef ()
void | Initialize (b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchorA, const b2Vec2 &anchorB)
## Public Attributes
b2Vec2 | localAnchorA
| The local anchor point relative to body1's origin.
b2Vec2 | localAnchorB
| The local anchor point relative to body2's origin.
float32 | length
| The natural length between the anchor points.
float32 | frequencyHz
| The mass-spring-damper frequency in Hertz.
float32 | dampingRatio
| The damping ratio. 0 = no damping, 1 = critical damping.

## Detailed Description

Distance joint definition. This requires defining an anchor point on both bodies and the non-zero length 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.

Warning:
  Do not use a zero or short length.

## Constructor & Destructor Documentation

b2DistanceJointDef::b2DistanceJointDef | ( |  | ) | `[inline]`

## Member Function Documentation

void b2DistanceJointDef::Initialize | ( | b2Body * | bodyA,
|  | b2Body * | bodyB,
|  | const b2Vec2 & | anchorA,
|  | const b2Vec2 & | anchorB |
| ) |  |  |

Initialize the bodies, anchors, and length using the world anchors.

## Member Data Documentation

float32 b2DistanceJointDef::dampingRatio

The damping ratio. 0 = no damping, 1 = critical damping.

float32 b2DistanceJointDef::frequencyHz

The mass-spring-damper frequency in Hertz.

float32 b2DistanceJointDef::length

The natural length between the anchor points.

b2Vec2 b2DistanceJointDef::localAnchorA

The local anchor point relative to body1's origin.

b2Vec2 b2DistanceJointDef::localAnchorB

The local anchor point relative to body2's origin.

The documentation for this struct was generated from the following files:

- Box2D/Box2D/Dynamics/Joints/b2DistanceJoint.h
- Box2D/Box2D/Dynamics/Joints/b2DistanceJoint.cpp