-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPoint.h
101 lines (75 loc) · 3.69 KB
/
Point.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* ██╗ ██╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗
██║ ██╔╝ ██╔══██╗ ╚══██╔══╝ ██╔══██╗ ████╗ ██║ ██╔══██╗
█████╔╝ ███████║ ██║ ███████║ ██╔██╗ ██║ ███████║
██╔═██╗ ██╔══██║ ██║ ██╔══██║ ██║╚██╗██║ ██╔══██║
██║ ██╗ ██║ ██║ ██║ ██║ ██║ ██║ ╚████║ ██║ ██║
╚═╝ ╚═╝ ╚═╝ ╚═╝/\ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝
/vvvvvvvvvvvvvvvvvvv \=========================================,
`^^^^^^^^^^^^^^^^^^^ /---------------------------------------"
Katana Engine \/ © 2012 - Shuriken Studios LLC */
#pragma once
namespace KatanaEngine
{
class Vector2;
/** @brief Defines a point in 2D space. */
class Point
{
public:
/** @brief Instantiates a new point object.
@param x The X component
@param y The Y component */
Point(const int x = 0, const int y = 0);
~Point() { };
static const Point Origin; /**< @brief A point located at the origin. */
/** @brief Sets the components of the point.
@param x The X component.
@param y The Y component. */
void Set(const int x, const int y);
/** @brief Sets the components of the vecpointtor.
@param point The point whose components to copy.
@overload */
void Set(const Point point);
/** @brief Determines if the point is located at the origin.
@return Returns true if both components are zero, false otherwise. */
bool IsOrigin() const { return (X == 0 && Y == 0); }
/** @brief Converts the point into a vector.
@return Returns a displacement vector to the point. */
const Vector2 ToVector2() const;
/** @brief Gets a string representation of the point.
@return Returns a string displaying the components of the point. */
std::string ToString() const;
/** @brief Prints the point to the console. */
void Display() const { std::cout << ToString() << std::endl; }
/** @brief Assigns the reference of a point.
@param point The reference point.
@return Returns the resulting point. */
Point &operator= (const Point &point);
/** @brief Adds a point.
@param point The point to add.
@return Returns the resulting point. */
Point &operator+=(const Point &point);
/** @brief Subtracts a point.
@param point The point to subtract.
@return Returns the resulting point. */
Point &operator-=(const Point &point);
/** @brief Adds two points.
@param point The point to add.
@return Returns the resulting point. */
const Point operator+(const Point &point) const;
/** @brief Subtracts a point from another.
@param point The point to subtract.
@return Returns the resulting point. */
const Point operator-(const Point &point) const;
/** @brief Determines if two points are equal.
@param point The point to compare.
@return Returns true if the points are equal, false otherwise. */
bool operator==(const Point &point) const;
/** @brief Determines if two points are not equal.
@param point The point to compare.
@return Returns true if the points are not equal, false otherwise. */
bool operator!=(const Point &point) const;
int X; /**< @brief The x-coordinate of the point. */
int Y; /**< @brief The y-coordinate of the point. */
};
}