-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVector2D.hpp
More file actions
39 lines (31 loc) · 923 Bytes
/
Copy pathVector2D.hpp
File metadata and controls
39 lines (31 loc) · 923 Bytes
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
#pragma once
#include "Point2D.hpp"
namespace CGF
{
class Vector2D
{
private:
float mX;
float mY;
public:
// Constructors
Vector2D() : mX(0), mY(0) {}
Vector2D(float x, float y) : mX(x), mY(y) {}
Vector2D(const Point2D& start, const Point2D& end) : mX(end.GetX() - start.GetX()), mY(end.GetY() - start.GetY()) {}
// Getters
float getX() const { return mX; }
float getY() const { return mY; }
// Setters
void setX(float x) { mX = x; }
void setY(float y) { mY = y; }
// Other member functions
float angle(const Vector2D &other) const;
float dot(const Vector2D &other) const;
float magnitude() const;
Vector2D normalize() const;
Vector2D operator+(const Vector2D& other) const;
Vector2D operator-(const Vector2D& other) const;
Vector2D operator*(float scalar) const;
Vector2D operator/(float scalar) const;
};
} // namespace CGF