Public Member Functions

bl7::rigidbodies2::Spring Class Reference

#include <Spring.h>

Inheritance diagram for bl7::rigidbodies2::Spring:
bl7::rigidbodies2::ForceGenerator

List of all members.

Public Member Functions

virtual ~Spring (void)
 Spring (RigidBody *body, const float d, const float s0, const ml7::Vector2 &local_point=ml7::Vector2(0.0f), const ml7::Vector2 &other_point=ml7::Vector2(0.0f))
RigidBodyget_attached_body () const
float get_spring_constant () const
float get_rest_length () const
const ml7::Vector2get_local_point () const
const ml7::Vector2get_attached_local_point () const
void set_attached_body (RigidBody *body)
void set_spring_constant (const float d)
void set_rest_length (const float s0)
void set_local_point (const ml7::Vector2 &local_point)
void set_attached_local_point (const ml7::Vector2 &other_point)

Detailed Description

A force generator that applies spring forces to 2d rigid bodies. One instance should not be used for multiple rigid bodies. However, you may attach one instance to a rigid body and apply the same spring force between this rigid bodies and multiple others. Notice that the force generator creates a force for only one object (the rigid body passed in to function update_force). If you want to link two objects with a spring, then you have to individually create and register a generator for each.


Constructor & Destructor Documentation

virtual bl7::rigidbodies2::Spring::~Spring ( void   )  [inline, virtual]

Destructor.

bl7::rigidbodies2::Spring::Spring ( RigidBody body,
const float  d,
const float  s0,
const ml7::Vector2 local_point = ml7::Vector2(0.0f),
const ml7::Vector2 other_point = ml7::Vector2(0.0f) 
) [inline]

Explicit constructor with parameters specifying the permanently attached rigid body on the other side of the spring, the spring constant d, the rest length of the spring s0 and, finally, the local connection points of the two rigid bodies the spring is attached to.


Member Function Documentation

RigidBody* bl7::rigidbodies2::Spring::get_attached_body (  )  const [inline]

Returns the rigid body permanently attached to the spring.

const ml7::Vector2& bl7::rigidbodies2::Spring::get_attached_local_point (  )  const [inline]

Returns the local connection point of the permanently attached rigid body.

const ml7::Vector2& bl7::rigidbodies2::Spring::get_local_point (  )  const [inline]

Returns the local connection point of the rigid body to apply forces to.

float bl7::rigidbodies2::Spring::get_rest_length (  )  const [inline]

Returns the rest length of the spring.

float bl7::rigidbodies2::Spring::get_spring_constant (  )  const [inline]

Returns the spring constant.

void bl7::rigidbodies2::Spring::set_attached_body ( RigidBody body  )  [inline]

Sets the rigid body permanently attached to the spring.

void bl7::rigidbodies2::Spring::set_attached_local_point ( const ml7::Vector2 other_point  )  [inline]

Sets the local connection point of the permanently attached rigid body.

void bl7::rigidbodies2::Spring::set_local_point ( const ml7::Vector2 local_point  )  [inline]

Sets the local connection point of the rigid body to apply forces to.

void bl7::rigidbodies2::Spring::set_rest_length ( const float  s0  )  [inline]

Sets the rest length of the spring.

void bl7::rigidbodies2::Spring::set_spring_constant ( const float  d  )  [inline]

Sets the spring constant.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines