-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.h
62 lines (50 loc) · 1.6 KB
/
math.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MATH_HEADER
#define MATH_HEADER
#include <ostream>
namespace Math
{
class Vector3
{
public:
Vector3();
Vector3(Vector3 const& v);
Vector3(float x, float y, float z);
float getX() const;
float getY() const;
float getZ() const;
Vector3& operator+=(Vector3 const& rhs);
Vector3& operator-=(Vector3 const& rhs);
Vector3 operator-() const;
float norm() const;
private:
float x, y, z;
void setX(float f);
void setY(float f);
void setZ(float f);
};
Vector3 operator+(Vector3 const& lhs, Vector3 const& rhs);
Vector3 operator-(Vector3 const& lhs, Vector3 const& rhs);
bool operator==(Vector3 const& lhs, Vector3 const& rhs);
bool operator!=(Vector3 const& lhs, Vector3 const& rhs);
Vector3 operator*(float const& lhs, Vector3 const& rhs);
Vector3 operator*(Vector3 const& lhs, float const& rhs);
Vector3 operator/(Vector3 const& lhs, float const& rhs);
std::ostream& operator<<(std::ostream &strm, const Vector3 &v);
float dot(Vector3 const& lhs, Vector3 const& rhs);
Vector3 cross(Vector3 const& lhs, Vector3 const& rhs);
struct Ray
{
Vector3 origin;
Vector3 direction;
};
// axis aligned box
class Box
{
public:
Vector3 min, max; // the vectors containing all min values and all max values respectively
Box(); // create the degenerate box that has min and max set to the origin
Box(Vector3 u, Vector3 v);
bool isInside(Vector3 p) const; // not edge inclusive
};
}
#endif