GigaPasjans
Loading...
Searching...
No Matches
Int2.h
1//Wykonane przez Piotra ChudziƄskiego w dniu 11.04.2025
2#pragma once
3
4#include "foundation/DataTypes.h"
5
10struct Int2
11{
12 union
13 {
14 struct
15 {
16 int32 X, Y;
17 };
18
19 int32 Raw[2];
20 };
21
22 constexpr Int2() : X(0), Y(0)
23 {
24 }
25
26 constexpr Int2(const int32 x, const int32 y) : X(x), Y(y)
27 {
28 }
29
30 const static Int2 Zero;
31 const static Int2 One;
32
33 int32 *GetValuePointer()
34 {
35 return Raw;
36 }
37
41bool operator==(const Int2& right) const
42{
43 return X == right.X && Y == right.Y;
44}
45
49Int2 operator+(const Int2& right) const
50{
51 return {X + right.X, Y + right.Y};
52}
53
57Int2 operator-(const Int2& right) const
58{
59 return {X - right.X, Y - right.Y};
60}
61
65bool operator<(const Int2& right) const
66{
67 return X < right.X && Y < right.Y;
68}
69
73bool operator>(const Int2& right) const
74{
75 return X > right.X && Y > right.Y;
76}
77
81bool operator<=(const Int2& right) const
82{
83 return X <= right.X && Y <= right.Y;
84}
85
89bool operator>=(const Int2& right) const
90{
91 return X >= right.X && Y >= right.Y;
92}
93
97Int2 operator+=(const Int2& right) const
98{
99 Int2 clone = {X, Y};
100 clone.X += right.X;
101 clone.Y += right.Y;
102 return clone;
103}
104
108Int2 operator-=(const Int2& right) const
109{
110 Int2 clone = {X, Y};
111 clone.X -= right.X;
112 clone.Y -= right.Y;
113 return clone;
114}
115
119Int2 operator*(const Int2& right) const
120{
121 return {X * right.X, Y * right.Y};
122}
123
127Int2 operator*(int32 value) const
128{
129 return {X * value, Y * value};
130}
131
135Int2 operator/(int32 value) const
136{
137 return {X / value, Y / value};
138}
139};
bool operator<(const Int2 &right) const
Checks if both components of this vector are less than those of another.
Definition Int2.h:65
Int2 operator*(int32 value) const
Multiplies both components of the vector by a scalar.
Definition Int2.h:127
Int2 operator-(const Int2 &right) const
Subtracts one Int2 vector from another.
Definition Int2.h:57
Int2 operator/(int32 value) const
Divides both components of the vector by a scalar.
Definition Int2.h:135
bool operator>(const Int2 &right) const
Checks if both components of this vector are greater than those of another.
Definition Int2.h:73
Int2 operator+=(const Int2 &right) const
Adds another Int2 vector to this one and returns the result.
Definition Int2.h:97
Int2 operator+(const Int2 &right) const
Adds two Int2 vectors.
Definition Int2.h:49
Int2 operator*(const Int2 &right) const
Multiplies two Int2 vectors component-wise.
Definition Int2.h:119
bool operator==(const Int2 &right) const
Compares two Int2 values for equality.
Definition Int2.h:41
Int2 operator-=(const Int2 &right) const
Subtracts another Int2 vector from this one and returns the result.
Definition Int2.h:108
bool operator<=(const Int2 &right) const
Checks if both components of this vector are less than or equal to those of another.
Definition Int2.h:81
bool operator>=(const Int2 &right) const
Checks if both components of this vector are greater than or equal to those of another.
Definition Int2.h:89