• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

step/stepcore

StepCore::Spring

StepCore::Spring Class Reference
[Physical forces]

Massless spring. More...

#include <spring.h>

Inheritance diagram for StepCore::Spring:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Spring (double restLength=0, double stiffness=1, double damping=0, Item *body1=0, Item *body2=0)
Object * body1 () const
Object * body2 () const
void calcForce (bool calcVariances)
double damping () const
double force () const
double length () const
Vector2d localPosition1 () const
Vector2d localPosition2 () const
Particle * particle1 () const
Particle * particle2 () const
Vector2d position1 () const
Vector2d position2 () const
double restLength () const
RigidBody * rigidBody1 () const
RigidBody * rigidBody2 () const
void setBody1 (Object *body1)
void setBody2 (Object *body2)
void setDamping (double damping)
void setLocalPosition1 (const Vector2d &localPosition1)
void setLocalPosition2 (const Vector2d &localPosition2)
void setRestLength (double restLength)
void setStiffness (double stiffness)
SpringErrors * springErrors ()
double stiffness () const
Vector2d velocity1 () const
Vector2d velocity2 () const

Protected Member Functions

ObjectErrors * createObjectErrors ()

Protected Attributes

Object * _body1
Object * _body2
double _damping
Vector2d _localPosition1
Vector2d _localPosition2
Particle * _p1
Particle * _p2
RigidBody * _r1
RigidBody * _r2
double _restLength
double _stiffness

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 ?

Definition at line 129 of file spring.h.


Constructor & Destructor Documentation

StepCore::Spring::Spring ( double  restLength = 0,
double  stiffness = 1,
double  damping = 0,
Item *  body1 = 0,
Item *  body2 = 0 
) [explicit]

Constructs Spring.

Definition at line 72 of file spring.cc.


Member Function Documentation

Object* StepCore::Spring::body1 (  )  const [inline]

Get pointer to the first body.

Definition at line 159 of file spring.h.

Object* StepCore::Spring::body2 (  )  const [inline]

Get pointer to the second body.

Definition at line 164 of file spring.h.

void StepCore::Spring::calcForce ( bool  calcVariances  )  [virtual]

Calculate force.

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

Implements StepCore::Force.

Definition at line 82 of file spring.cc.

ObjectErrors* StepCore::Spring::createObjectErrors (  )  [inline, protected, virtual]

For internal use only.

Creates specific ObjectErrors-derived class (to be reimplemented in derived classes)

Reimplemented from StepCore::Item.

Definition at line 217 of file spring.h.

double StepCore::Spring::damping (  )  const [inline]

Get damping of the spring.

Definition at line 154 of file spring.h.

double StepCore::Spring::force (  )  const

Tension force.

Definition at line 256 of file spring.cc.

double StepCore::Spring::length (  )  const [inline]

Get current length of the spring.

Definition at line 146 of file spring.h.

Vector2d StepCore::Spring::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).

Definition at line 170 of file spring.h.

Vector2d StepCore::Spring::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).

Definition at line 177 of file spring.h.

Particle* StepCore::Spring::particle1 (  )  const [inline]

Get first connected Particle.

Definition at line 202 of file spring.h.

Particle* StepCore::Spring::particle2 (  )  const [inline]

Get second connected Particle.

Definition at line 204 of file spring.h.

Vector2d StepCore::Spring::position1 (  )  const

Position of the first end of the spring.

Definition at line 177 of file spring.cc.

Vector2d StepCore::Spring::position2 (  )  const

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

Position of the second end of the spring

Definition at line 198 of file spring.cc.

double StepCore::Spring::restLength (  )  const [inline]

Get rest length of the spring.

Definition at line 141 of file spring.h.

RigidBody* StepCore::Spring::rigidBody1 (  )  const [inline]

Get first connected RigidBody.

Definition at line 206 of file spring.h.

RigidBody* StepCore::Spring::rigidBody2 (  )  const [inline]

Get second connected RigidBody.

Definition at line 208 of file spring.h.

void StepCore::Spring::setBody1 ( Object *  body1  ) 

Set pointer to the first connected body.

Definition at line 137 of file spring.cc.

void StepCore::Spring::setBody2 ( Object *  body2  ) 

Set pointer to the second connected body.

Definition at line 157 of file spring.cc.

void StepCore::Spring::setDamping ( double  damping  )  [inline]

Set damping of the spring.

Definition at line 156 of file spring.h.

void StepCore::Spring::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).

Definition at line 173 of file spring.h.

void StepCore::Spring::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).

Definition at line 180 of file spring.h.

void StepCore::Spring::setRestLength ( double  restLength  )  [inline]

Set rest length of the spring.

Definition at line 143 of file spring.h.

void StepCore::Spring::setStiffness ( double  stiffness  )  [inline]

Set stiffness of the spring.

Definition at line 151 of file spring.h.

SpringErrors* StepCore::Spring::springErrors (  )  [inline]

Get (and possibly create) SpringErrors object.

Definition at line 214 of file spring.h.

double StepCore::Spring::stiffness (  )  const [inline]

Get stiffness of the spring.

Definition at line 149 of file spring.h.

Vector2d StepCore::Spring::velocity1 (  )  const

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

Velocity of the first end of the spring

Definition at line 222 of file spring.cc.

Vector2d StepCore::Spring::velocity2 (  )  const

Velocity of the second end of the spring.

Definition at line 239 of file spring.cc.


Member Data Documentation

Object* StepCore::Spring::_body1 [protected]

Definition at line 219 of file spring.h.

Object* StepCore::Spring::_body2 [protected]

Definition at line 220 of file spring.h.

double StepCore::Spring::_damping [protected]

Definition at line 223 of file spring.h.

Vector2d StepCore::Spring::_localPosition1 [protected]

Definition at line 224 of file spring.h.

Vector2d StepCore::Spring::_localPosition2 [protected]

Definition at line 225 of file spring.h.

Particle* StepCore::Spring::_p1 [protected]

Definition at line 227 of file spring.h.

Particle* StepCore::Spring::_p2 [protected]

Definition at line 228 of file spring.h.

RigidBody* StepCore::Spring::_r1 [protected]

Definition at line 229 of file spring.h.

RigidBody* StepCore::Spring::_r2 [protected]

Definition at line 230 of file spring.h.

double StepCore::Spring::_restLength [protected]

Definition at line 221 of file spring.h.

double StepCore::Spring::_stiffness [protected]

Definition at line 222 of file spring.h.


The documentation for this class was generated from the following files:
  • spring.h
  • spring.cc

step/stepcore

Skip menu "step/stepcore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  •     lib
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal