-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCartesian3.h
More file actions
78 lines (58 loc) · 1.89 KB
/
Cartesian3.h
File metadata and controls
78 lines (58 loc) · 1.89 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
67
68
69
70
71
72
73
74
75
76
77
78
//////////////////////////////////////////////////////////////////////
//
// University of Leeds
// COMP 5812M Foundations of Modelling & Rendering
// User Interface for Coursework
//
// September, 2020
//
// ------------------------
// Cartesian3.h
// ------------------------
//
// A minimal class for a point in Cartesian space
//
///////////////////////////////////////////////////
#ifndef CARTESIAN3_H
#define CARTESIAN3_H
#include <iostream>
// the class - we will rely on POD for sending to GPU
class Cartesian3
{ // Cartesian3
public:
// the coordinates
float x, y, z;
// constructors
Cartesian3();
Cartesian3(float X, float Y, float Z);
// equality operator
bool operator ==(const Cartesian3 &other) const;
// unary minus operator
Cartesian3 operator-() const;
// addition operator
Cartesian3 operator +(const Cartesian3 &other) const;
// subtraction operator
Cartesian3 operator -(const Cartesian3 &other) const;
// multiplication operator
Cartesian3 operator *(float factor) const;
// division operator
Cartesian3 operator /(float factor) const;
// dot product routine
float dot(const Cartesian3 &other) const;
// cross product routine
Cartesian3 cross(const Cartesian3 &other) const;
// routine to find the length
float length() const;
// normalisation routine
Cartesian3 unit() const;
// operator that allows us to use array indexing instead of variable names
float &operator [] (const int index);
const float &operator [] (const int index) const;
}; // Cartesian3
// multiplication operator
Cartesian3 operator *(float factor, const Cartesian3 &right);
// stream input
std::istream & operator >> (std::istream &inStream, Cartesian3 &value);
// stream output
std::ostream & operator << (std::ostream &outStream, const Cartesian3 &value);
#endif