-
Notifications
You must be signed in to change notification settings - Fork 0
/
vector.h
35 lines (28 loc) · 1011 Bytes
/
vector.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
#pragma once
namespace Math {
struct Vector2D {
float x;
float y;
Vector2D() {}
Vector2D(float x, float y): x(x), y(y) {}
};
Vector2D operator*(float a, const Vector2D& vec);
Vector2D operator+(const Vector2D& u, const Vector2D& v);
Vector2D operator+(float a, const Vector2D& v);
Vector2D operator-(const Vector2D& u, const Vector2D& v);
Vector2D operator/(const Vector2D& v, float a);
struct Vector3D: public Vector2D {
float z;
Vector3D() : Vector2D() {}
Vector3D(float x, float y, float z): Vector2D(x, y), z(z) {}
};
float length(const Vector3D& v);
Vector3D normalize(const Vector3D& v);
Vector3D operator^(const Vector3D& u, const Vector3D& v);
float operator*(const Vector3D& u, const Vector3D& v);
Vector3D operator*(float a, const Vector3D& vec);
Vector3D operator+(const Vector3D& u, const Vector3D& v);
Vector3D operator+(float a, const Vector3D& v);
Vector3D operator-(const Vector3D& u, const Vector3D& v);
Vector3D operator/(const Vector3D& v, float a);
}