diff options
author | mutantturkey <mutantturke@gmail.com> | 2012-06-14 18:34:23 -0400 |
---|---|---|
committer | mutantturkey <mutantturke@gmail.com> | 2012-06-14 18:34:23 -0400 |
commit | 53b73dec4d6e71899d183335509591b7c89a419b (patch) | |
tree | 256e96682ba4ce1bcb1aa86d228a212a0193197b /fly-tools/FlyObject.cpp | |
parent | bc2747f47bc2153642da518ea8afa7f5b4859819 (diff) |
pushing the fly-tools into this repository
Diffstat (limited to 'fly-tools/FlyObject.cpp')
-rw-r--r-- | fly-tools/FlyObject.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/fly-tools/FlyObject.cpp b/fly-tools/FlyObject.cpp new file mode 100644 index 0000000..d6cbee3 --- /dev/null +++ b/fly-tools/FlyObject.cpp @@ -0,0 +1,118 @@ +/* + * FlyObject.cpp + * + * + * Created by Md. Alimoor Reza on 6/26/10. + * Copyright 2010 Drexel University. All rights reserved. + * + */ + +#include "FlyObject.h" + +FlyObject::FlyObject(int area, pair<int, int> centroid, pair<double,double> majorAxisEV, pair<double,double> velocityV,bool headIsInDirectionMAEV, pair<double,double> head, double speed) { +//FlyObject::FlyObject(int area, pair<int, int> centroid, pair<double,double> majorAxisEV, pair<double,double> velocityV, vector<pair<int , int> > areaCoord) { + this->area = area; + this->centroid = centroid; + this->majorAxisEV = majorAxisEV; + this->velocityV = velocityV; + this->headIsInDirectionMAEV = headIsInDirectionMAEV; + this->head = head; + this->speed = speed; +// this->areaCoord = areaCoord; +} + +FlyObject::FlyObject(const FlyObject &f){ + this->area = f.getArea(); + this->centroid=f.getCentroid(); + this->majorAxisEV =f.getMajorAxisEV(); + this->velocityV = f.getVelocityV(); +// this->areaCoord = f.getAreaCoord(); + this->headIsInDirectionMAEV = f.getHeadIsInDirectionMAEV(); + this->head = f.getHead(); + this->speed = f.getSpeed(); +} + +int FlyObject::getArea() const { + return area; +} + +pair<int, int> FlyObject::getCentroid() const { + return this->centroid; +} + +pair<double,double> FlyObject::getMajorAxisEV() const { + return this->majorAxisEV; +} + +pair<double,double> FlyObject::getVelocityV() const { + return this->velocityV; +} +bool FlyObject::getHeadIsInDirectionMAEV() const { + return this->headIsInDirectionMAEV; +} +pair<double,double> FlyObject::getHead() const { + return this->head; +} +//vector<pair<int , int> > FlyObject::getAreaCoord() const { +// return this->areaCoord; +//} +double FlyObject::getSpeed() const { + return this->speed; +} +void FlyObject::setArea(int area) { + this->area = area; +} + +void FlyObject::setCentroid(pair<int, int> centroid) { + this->centroid = centroid; +} + +void FlyObject::setMajorAxisEV(pair<double,double> majorAxisEV) { + this->majorAxisEV = majorAxisEV; +} + +void FlyObject::setVelocityV(pair<double,double> velocityV) { + this->velocityV = velocityV; +// cout << "velocityV is set to "<<this->velocityV.first<<","<<this->velocityV.second<<endl; +} +void FlyObject::setHead(pair<double, double> head) { + this->head = head; + cout << "new head is set"<<endl; + +} +//void FlyObject::setAreaCoord(vector<pair<int, int> > areaCoord){ +// this->areaCoord = areaCoord; +//} +void FlyObject::setSpeed(double speed) { + this->speed = speed; +} + +void FlyObject::normalizeVelocity() { + double temp = velocityV.first*velocityV.first + velocityV.second*velocityV.second; + temp = sqrt(temp); + cout << "sum = "<<temp<<endl; + cout << "unnormalized velocity "<<velocityV.first<<","<<velocityV.second<<endl; + if (temp != 0) { + velocityV.first = velocityV.first/temp; + velocityV.second = velocityV.second/temp; + cout << "unit velocity "<<velocityV.first<<","<<velocityV.second<<endl; + } else { + cout <<"velocity zero"<<endl; + } + +} +void FlyObject::setHeadIsInDirectionMAEV(bool headIsInDirectionMAEV) { + this->headIsInDirectionMAEV = headIsInDirectionMAEV; + cout << "head flag set to "<<this->headIsInDirectionMAEV<<endl; +} + + +void FlyObject::output(ostream &out) { + out<<"Area : "<<area<<endl; + out<<"Centroid : ("<<centroid.first<<","<<centroid.second<<")"<<endl; + out<<"MajorAxisEV : ("<<majorAxisEV.first<<","<<majorAxisEV.second<<")"<<endl; + out<<"VelocityV : ("<<velocityV.first<<","<<velocityV.second<<")"<<endl; + out<<"HeadIsInDir : "<<this->headIsInDirectionMAEV<<endl; + out<<"Head : ("<<this->head.first<<","<<head.second<<endl; + out<<"Speed : "<<speed<<endl; +}
\ No newline at end of file |