-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathECE_UAV.h
More file actions
89 lines (61 loc) · 2.01 KB
/
Copy pathECE_UAV.h
File metadata and controls
89 lines (61 loc) · 2.01 KB
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
//
// Created by mehak on 12/6/2021.
//
#pragma once
#include <thread>
#include <atomic>
#ifndef OPENGLPROJECT_ECE_UAV_H
#define OPENGLPROJECT_ECE_UAV_H
//Euclidean Distance between two vectors
double distance(glm::vec3 p1, glm::vec3 p2);
//Direction vector form point 2 to point 1
glm::vec3 subtract(glm::vec3 p1, glm::vec3 p2);
class ECE_UAV
{
private:
glm::vec3 position;
glm::vec3 velocity;
glm::vec3 acceleration;
glm::vec3 directionVector; //points from uav to target
glm::vec3 tangentVector; //a normal vector to the current direction vector
int pos;
double mass;
bool circularMotion;
double circularStart;
std::thread thread;
std::atomic<bool> startFlying;
std::atomic<bool> allDone;
//Function that finds the vector pointing from uav position to the center of the sphere and a random vector normal to this direction vector
void updateVectors();
public:
void printt()
{
std::cout << this->thread.get_id() <<std::endl;
}
//Constructor function
ECE_UAV ();
glm::vec3 getPosition();
glm::vec3 getVelocity();
void setPosition(glm::vec3 pos);
void setVelocity(glm::vec3 vel);
void setFlight();
void setAllDone();
bool getAllDone();
bool getCircularStart();
void setCircularTime(double time);
//Sets the initial position of the uavs on the football field
void initPos(int i);
//Update position vector to simulate the motion of uavs
void updatePosition(double delta, double distanceThreshold);
//Checks if the uav has been in circular motion for 60 seconds
bool flySixty(double time);
//Starts the thread function
void start();
};
//Function to exchange velocities and set uavs some distance apart after collision is detected
void doIfCollide(ECE_UAV &object1, ECE_UAV &object2);
//Function to detect elastic collision
int elasticCollision(ECE_UAV *uavs, int num);
//Function that the thread object runs
void threadFunction(ECE_UAV* pUAV);
#endif //OPENGLPROJECT_ECE_UAV_H