Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ElasticLink.cpp

Go to the documentation of this file.
00001 // ElasticLink.cpp: implementation of the ElasticLink class.
00002 //
00004 
00005 #include "ElasticLink.h"
00006 
00008 // Construction/Destruction
00010 
00011 ElasticLink::ElasticLink(PhysicalObject* object1, PhysicalObject* object2, real length, real k):
00012 object1(object1),object2(object2),length(length),k(k){
00013 
00014 }
00015 
00016 ElasticLink::~ElasticLink(){
00017 
00018 }
00019 
00020 void ElasticLink::applyForces(){
00021    Vector2 r=object1->r;
00022    r-=object2->r;
00023    real d=r.getModule();
00024    r*=k*(1-length/d);
00025    object1->externalForce-=r;
00026    object2->externalForce+=r;
00027 }
00028 
00029 void ElasticLink::draw(GUI* gui){
00030    gui->drawLine(object1->r,object2->r);
00031 }

Thyrix homepageUsers' guide

(C) Arxia 2004-2005