1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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;
}
|