-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVector2D.h
41 lines (31 loc) · 927 Bytes
/
Vector2D.h
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
#ifndef VECTOR2D_H
#define VECTOR2D_H
#include<math.h>
class Vector2D
{
public:
//Constructors
Vector2D();
Vector2D(float x, float y);
//Operators
Vector2D operator+(const Vector2D& v2);
Vector2D operator+=(const Vector2D& v2);
Vector2D operator-(const Vector2D& v2);
Vector2D operator-=(const Vector2D& v2);
Vector2D operator*(float scalar);
Vector2D operator*=(float scalar);
Vector2D operator/(float scalar);
Vector2D operator/=(float scalar);
//GETs
float getX() const;
float getY() const;
float length() const; //lenght of the vector = sqrt(x²+y²)
//Methods
void setX(float x); //change x value
void setY(float y); //change y value
void normalize(); //make vector length = 1
private:
float m_x;
float m_y;
};
#endif // VECTOR2D_H