-
Notifications
You must be signed in to change notification settings - Fork 0
/
Point3D.hpp
executable file
·79 lines (62 loc) · 1.49 KB
/
Point3D.hpp
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
79
#pragma once
#include <iostream>
#include <type_traits>
#include "Color.hpp"
template <typename T=int>
requires std::is_arithmetic_v<T>
struct Point3D
{
T x,y,z;
Color color;
void setColor(const Color& col)
{
color = col;
}
// Construct from XYZ & Color
Point3D(T X=0, T Y=0, T Z=0, const Color& COLOR={})
: x(X), y(Y), z(Z), color(COLOR) {}
// Default Copy Constructor
Point3D(const Point3D& pnt) = default;
// Default Assignment Operator
Point3D& operator= (const Point3D&) = default;
// Comparison Operators //
bool operator == (const Point3D& rhs) const
{
return (x == rhs.x) && (y == rhs.y) && (z == rhs.z);
}
bool operator < (const Point3D& rhs) const
{
return (x < rhs.x) || (y < rhs.y) || (z < rhs.z);
}
bool operator > (const Point3D& rhs) const
{
return (x > rhs.x) || (y > rhs.y) || (z > rhs.z);
}
bool operator << (const Point3D& rhs) const
{
return (x < rhs.x) && (y < rhs.y) && (z < rhs.z);
}
bool operator >> (const Point3D& rhs) const
{
return (x > rhs.x) && (y > rhs.y) && (z > rhs.z);
}
// Arithmatic Operators //
template <typename T2>
Point3D<T> operator + (const Point3D<T2>& rhs)
{
return {x + rhs.x, y + rhs.y, z + rhs.z};
}
/*
Point3D operator - (const Point3D<auto>& rhs)
{
return {x - rhs.x, y - rhs.y, z - rhs.z};
}
Point3D operator * (const Point3D<auto>& rhs)
{
return {x * rhs.x, y * rhs.y, z * rhs.z};
}
Point3D operator / (const Point3D<auto>& rhs)
{
return {x / rhs.x, y / rhs.y, z / rhs.z};
}*/
};