-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNormal.h
More file actions
66 lines (61 loc) · 2.15 KB
/
Copy pathNormal.h
File metadata and controls
66 lines (61 loc) · 2.15 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
#pragma once
class Matrix;
class Vector3D;
class Point3D;
class Ray;
class Normal
{
public:
union { struct { float x, y, z; }; float cell[3]; };
public:
// Constructors
// Defult Constructor
Normal();
// Construct from one value
inline Normal(const float value);
// Construct from three values
inline Normal(const float x_value, const float y_value, const float z_value);
// Copy Constructor, from a Normal
Normal(const Normal& nrml);
// Copy Constructor, from a Vector3D
Normal(const Vector3D& vec3);
// Destructor
inline ~Normal();
// Assignment Operator, from a Normal
Normal& operator=(const Normal& nrml);
// Assignment Operator, from a Vector3D
Normal& operator=(const Vector3D& vec3);
// Assignment Operator, from a Point3D
Normal& operator=(const Point3D& p3d);
// Unary minus
Normal operator-() const;
// Addition
Normal operator+ (const Normal& nrml) const;
// Compound Addition
Normal& operator+= (const Normal& nrml);
// Dot product with a Vector3D on the right
float operator* (const Vector3D& vec3) const;
// Dot product with a Normal on the right
float operator* (const Normal& nrml) const;
// Multipilication by a float on the right
Normal operator* (const float value) const;
// Normalize the normal to a unit one
void normalize();
};
// Non-member functions
// multiplication by a float on the left
Normal operator* (const float a, const Normal& n);
// addition of a vector on the left to return a vector
Vector3D operator+ (const Vector3D& v, const Normal& n);
// addition of a Point3D on the left to return a Point3D
Point3D operator+ (const Point3D& p3d, const Normal& n);
// subtraction of a normal from a vector to return a vector
Vector3D operator- (const Vector3D&, const Normal& n);
// dot product of a Vector3D on the left and a Normal on the right
float operator* (const Vector3D& v, const Normal& n);
// dot product of a Ray on the left and a Normal on the right
float operator* (const Ray& ray, const Normal& n);
// dot product of a Point3D on the left and a Normal on the right
float operator* (const Point3D& p3d, const Normal& n);
// multiplication by a matrix on the left
Normal operator* (const Matrix& mat, const Normal& n);