Spring Class Reference
[Physical forces]

Massless spring. More...

#include <spring.h>

Inheritance diagram for Spring:

Item Force PairForce Object List of all members.

Public Member Functions

 Spring (double restLength=0, double stiffness=1, Body *bodyPtr1=0, Body *bodyPtr2=0)
void calcForce ()
double restLength () const
void setRestLength (double restLength)
double length () const
double stiffness () const
void setStiffness (double stiffness)
void setBodyPtr1 (Body *bodyPtr1)
void setBodyPtr2 (Body *bodyPtr2)
void setBody1 (const QString &body1)
void setBody2 (const QString &body2)
QString body1 () const
QString body2 () const
Vector2d localPosition1 () const
void setLocalPosition1 (const Vector2d &localPosition1)
Vector2d localPosition2 () const
void setLocalPosition2 (const Vector2d &localPosition2)
Vector2d position1 () const
Vector2d position2 () const
void worldItemRemoved (Item *item)
void setWorld (World *world)
Worldworld () const
const QString & name () const
void setName (const QString &name)
BodybodyPtr1 ()
BodybodyPtr2 ()

Detailed Description

Massless spring.

Massless spring is the force between two selected bodies which equals:

\[ \overrightarrow{f} = k (\overrightarrow{r} - \overrightarrow{r_0}) \]

where:
$k$ is Spring::stiffness
$\overrightarrow{r}$ is difference of Particle::position of the first and second body
$\overrightarrow{r_0}$ is Spring::restLength

Todo:
how to move setBody1() and setBody2() to PairForce ?


Constructor & Destructor Documentation

Spring ( double  restLength = 0,
double  stiffness = 1,
Body bodyPtr1 = 0,
Body bodyPtr2 = 0 
)

Constructs Spring


Member Function Documentation

void calcForce (  )  [virtual]

Calculate force. Bodies can be accessed through this->world()->bodies()

Implements Force.

double restLength (  )  const [inline]

Get rest length of the spring

void setRestLength ( double  restLength  )  [inline]

Set rest length of the spring

double length (  )  const [inline]

Get current length of the spring

double stiffness (  )  const [inline]

Get stiffness of the spring

void setStiffness ( double  stiffness  )  [inline]

Set stiffness of the spring

void setBodyPtr1 ( Body bodyPtr1  ) 

Set pointer to the first connected body

Todo:
XXX check world

void setBodyPtr2 ( Body bodyPtr2  ) 

Set pointer to the second connected body

Todo:
XXX check world

void setBody1 ( const QString &  body1  ) 

Set first connected body by name

void setBody2 ( const QString &  body2  ) 

Set second connected body by name

QString body1 (  )  const [inline]

Get name of the first connected body

QString body2 (  )  const [inline]

Get name of the second connected body

Vector2d localPosition1 (  )  const [inline]

Local position of the first end of the spring on the body or in the world (if the end is not connected)

void setLocalPosition1 ( const Vector2d localPosition1  )  [inline]

Set local position of the first end of the spring on the body or in the world (if the end is not connected)

Vector2d localPosition2 (  )  const [inline]

Local position of the second end of the spring on the body or in the world (if the end is not connected)

void setLocalPosition2 ( const Vector2d localPosition2  )  [inline]

Set local position of the second end of the spring on the body or in the world (if the end is not connected)

Vector2d position1 (  )  const

Position of the first end of the spring

Vector2d position2 (  )  const

Position of the second end of the spring

void worldItemRemoved ( Item item  )  [virtual]

Set position of the second end of the spring (will be ignored the end is connected)

Reimplemented from Item.

void setWorld ( World world  )  [virtual]

Set/change pointer to World in which this object lives

Reimplemented from Item.

World* world (  )  const [inline, inherited]

Get pointer to World in which this object lives

Returns:
Pointer to the World or NULL

const QString& name (  )  const [inline, inherited]

Returns name of the object

void setName ( const QString &  name  )  [inline, inherited]

Set name of the object

Body* bodyPtr1 (  )  [inline, inherited]

Get pointer to the first body

Body* bodyPtr2 (  )  [inline, inherited]

Get pointer to the second body


The documentation for this class was generated from the following files:
Generated on Thu Mar 15 14:23:37 2007 for StepCore by  doxygen 1.5.1