![]() |
00001 #include "ArticulatedLimb.h" 00002 #include "Simulator.h" 00003 #include "purgeContainer.h" 00004 00005 /* 00006 ArticulatedLimb::ArticulatedLimb(){ 00007 l=0.0; 00008 theta=0.0; 00009 } 00010 */ 00011 00012 ArticulatedLimb::ArticulatedLimb(real iniL, real iniTheta) : 00013 l(iniL), 00014 theta(iniTheta) 00015 { 00016 } 00017 00018 ArticulatedLimb::~ArticulatedLimb(){ 00019 } 00020 00021 00022 ArticulatedLink* ArticulatedLimb::addLink() { 00023 int n = links.size() + 1; 00024 char s[20]; 00025 sprintf(s, "%d", n); 00026 ArticulatedLink* link=new ArticulatedLink(label + ": link " + s); 00027 links.push_back(link); 00028 return link; 00029 } 00030 00031 ArticulatedLink* ArticulatedLimb::addOneObjectLink(real l, real theta0, 00032 PhysicalObject* object, 00033 real x, real y, real alpha, 00034 ArticulatedLink* parent, bool hasElasticTorque){ 00035 ArticulatedLink* link; 00036 link=addLink(); 00037 link->l=l; 00038 link->theta0=theta0; 00039 link->theta=link->theta0; 00040 link->computeSinCos(); 00041 link->addObject(object, x, y, alpha); 00042 link->computeIStar0(); 00043 link->setParentLink(parent); 00044 link->hasElasticTorque=hasElasticTorque; 00045 return link; 00046 } 00047 00048 void ArticulatedLimb::computeSinCos(){ 00049 sinTheta=sin(theta); 00050 cosTheta=cos(theta); 00051 sin2=sinTheta*sinTheta; 00052 cos2=cosTheta*cosTheta; 00053 sinCos=sinTheta*cosTheta; 00054 } 00055 00056 void ArticulatedLimb::setProperties(real l, real theta) { 00057 this->l=l; 00058 this->theta=theta; 00059 computeSinCos(); 00060 } 00061 00062 void ArticulatedLimb::deleteLinks(){ 00063 purgeContainer(links); 00064 } 00065 00066 void ArticulatedLimb::draw(GUI *gui){ 00067 for (ArticulatedLinkPVector::iterator it = links.begin(), 00068 end = links.end(); it != end; ++it) { 00069 (*it)->draw(gui); 00070 00071 //draw bounding boxes of the links 00072 //gui->drawRectangle((*it)->boxMin.x,(*it)->boxMin.y,(*it)->boxMax.x-(*it)->boxMin.x,(*it)->boxMax.y-(*it)->boxMin.y); 00073 } 00074 } 00075 00076 void ArticulatedLimb::setOutlineColor(Color color){ 00077 for (ArticulatedLinkPVector::iterator it = links.begin(), 00078 end = links.end(); it != end; ++it) { 00079 (*it)->setOutlineColor(color); 00080 } 00081 } 00082 00083 void ArticulatedLimb::setFillColor(Color color){ 00084 for (ArticulatedLinkPVector::iterator it = links.begin(), 00085 end = links.end(); it != end; ++it) { 00086 (*it)->setFillColor(color); 00087 } 00088 }
![]() |
Thyrix homepage Users' guide
(C) Arxia 2004-2005