#include <spring.h>
Inheritance diagram for Spring:
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) |
World * | world () const |
const QString & | name () const |
void | setName (const QString &name) |
Body * | bodyPtr1 () |
Body * | bodyPtr2 () |
Massless spring is the force between two selected bodies which equals:
where:
is Spring::stiffness
is difference of Particle::position of the first and second body
is Spring::restLength
Constructs Spring
void calcForce | ( | ) | [virtual] |
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 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] |
World* world | ( | ) | const [inline, inherited] |
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