Leviathan  0.8.0.0
Leviathan game engine
Leviathan::Int2 Struct Reference

#include <Types.h>

Public Member Functions

DLLEXPORT constexpr Int2 () noexcept=default
 
DLLEXPORT constexpr Int2 (int x, int y) noexcept
 
DLLEXPORT constexpr Int2 (int data) noexcept
 
DLLEXPORT int & operator[] (int nindex)
 
DLLEXPORT constexpr Int2 operator+ (const Int2 &other) const noexcept
 
DLLEXPORT Int2operator+= (const Int2 &other) noexcept
 
DLLEXPORT constexpr Int2 operator- (const Int2 &other) const noexcept
 
DLLEXPORT Int2operator-= (const Int2 &other) noexcept
 
DLLEXPORT constexpr Int2 operator- () const noexcept
 
DLLEXPORT constexpr Int2 operator+ () const noexcept
 
DLLEXPORT constexpr Int2 operator* (const Int2 &other) const noexcept
 
DLLEXPORT Int2operator*= (const Int2 &other) noexcept
 
DLLEXPORT constexpr Int2 operator/ (int val) const
 
DLLEXPORT Int2operator/= (int val)
 
DLLEXPORT constexpr Int2 operator* (int val) const noexcept
 
DLLEXPORT Int2operator*= (int val) noexcept
 
DLLEXPORT constexpr Int2 operator/ (const Int2 &other) const
 
DLLEXPORT Int2operator/= (const Int2 &other)
 
DLLEXPORT constexpr bool operator< (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator<= (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator> (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator>= (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator== (const Int2 &other) const noexcept
 
DLLEXPORT constexpr bool operator!= (const Int2 &other) const noexcept
 
DLLEXPORT constexpr int GetX () const noexcept
 
DLLEXPORT constexpr int GetY () const noexcept
 
DLLEXPORT void SetX (int val)
 
DLLEXPORT void SetY (int val)
 
DLLEXPORT constexpr int HAdd () const noexcept
 
DLLEXPORT unsigned int HAddAbs () const noexcept
 
DLLEXPORT constexpr Int2 MinElements (const Int2 &other) const noexcept
 
DLLEXPORT constexpr Int2 MaxElements (const Int2 &other) const noexcept
 
DLLEXPORT constexpr Int2 Clamp (const Int2 &min, const Int2 &max) const noexcept
 
DLLEXPORT float Length () const noexcept
 
DLLEXPORT constexpr unsigned int LengthSquared () const noexcept
 
 VALUE_TYPE (Int2)
 

Public Attributes

int X = 0
 
int Y = 0
 

Detailed Description

Definition at line 203 of file Types.h.

Constructor & Destructor Documentation

◆ Int2() [1/3]

DLLEXPORT constexpr Leviathan::Int2::Int2 ( )
defaultnoexcept

◆ Int2() [2/3]

DLLEXPORT constexpr Leviathan::Int2::Int2 ( int  x,
int  y 
)
inlinenoexcept

Definition at line 207 of file Types.h.

207 : X(x), Y(y) {}

◆ Int2() [3/3]

DLLEXPORT constexpr Leviathan::Int2::Int2 ( int  data)
inlineexplicitnoexcept

Definition at line 208 of file Types.h.

208 : X(data), Y(data) {}

Member Function Documentation

◆ Clamp()

DLLEXPORT constexpr Int2 Leviathan::Int2::Clamp ( const Int2 min,
const Int2 max 
) const
inlinenoexcept

Definition at line 393 of file Types.h.

394  {
395  const Int2 minval = this->MinElements(max);
396  return min.MaxElements(minval);
397  }
DLLEXPORT constexpr Int2 MinElements(const Int2 &other) const noexcept
Definition: Types.h:382
DLLEXPORT constexpr Int2() noexcept=default

◆ GetX()

DLLEXPORT constexpr int Leviathan::Int2::GetX ( ) const
inlinenoexcept

Definition at line 348 of file Types.h.

349  {
350  return X;
351  }

◆ GetY()

DLLEXPORT constexpr int Leviathan::Int2::GetY ( ) const
inlinenoexcept

Definition at line 353 of file Types.h.

354  {
355  return Y;
356  }

◆ HAdd()

DLLEXPORT constexpr int Leviathan::Int2::HAdd ( ) const
inlinenoexcept

Definition at line 370 of file Types.h.

371  {
372  return X + Y;
373  }

◆ HAddAbs()

DLLEXPORT unsigned int Leviathan::Int2::HAddAbs ( ) const
inlinenoexcept

Definition at line 376 of file Types.h.

377  {
378  return std::abs(X) + std::abs(Y);
379  }

◆ Length()

DLLEXPORT float Leviathan::Int2::Length ( ) const
inlinenoexcept

Definition at line 401 of file Types.h.

402  {
403  return std::sqrt(static_cast<float>(LengthSquared()));
404  }
DLLEXPORT constexpr unsigned int LengthSquared() const noexcept
Definition: Types.h:406

◆ LengthSquared()

DLLEXPORT constexpr unsigned int Leviathan::Int2::LengthSquared ( ) const
inlinenoexcept

Definition at line 406 of file Types.h.

407  {
408  return X * X + Y * Y;
409  }

◆ MaxElements()

DLLEXPORT constexpr Int2 Leviathan::Int2::MaxElements ( const Int2 other) const
inlinenoexcept

Definition at line 387 of file Types.h.

388  {
389  return Int2(X > other.X ? X : other.X, Y > other.Y ? Y : other.Y);
390  }
DLLEXPORT constexpr Int2() noexcept=default

◆ MinElements()

DLLEXPORT constexpr Int2 Leviathan::Int2::MinElements ( const Int2 other) const
inlinenoexcept

Definition at line 382 of file Types.h.

383  {
384  return Int2(X < other.X ? X : other.X, Y < other.Y ? Y : other.Y);
385  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator!=()

DLLEXPORT constexpr bool Leviathan::Int2::operator!= ( const Int2 other) const
inlinenoexcept

Definition at line 341 of file Types.h.

342  {
343  return X != other.X || Y != other.Y;
344  }

◆ operator*() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator* ( const Int2 other) const
inlinenoexcept

Definition at line 263 of file Types.h.

264  {
265  return Int2(X * other.X, Y * other.Y);
266  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator*() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator* ( int  val) const
inlinenoexcept

Definition at line 289 of file Types.h.

290  {
291  return Int2(X * val, Y * val);
292  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator*=() [1/2]

DLLEXPORT Int2& Leviathan::Int2::operator*= ( const Int2 other)
inlinenoexcept

Definition at line 268 of file Types.h.

269  {
270  X *= other.X;
271  Y *= other.Y;
272  return *this;
273  }

◆ operator*=() [2/2]

DLLEXPORT Int2& Leviathan::Int2::operator*= ( int  val)
inlinenoexcept

Definition at line 294 of file Types.h.

295  {
296  X *= val;
297  Y *= val;
298  return *this;
299  }

◆ operator+() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator+ ( const Int2 other) const
inlinenoexcept

Definition at line 225 of file Types.h.

226  {
227  return Int2(X + other.X, Y + other.Y);
228  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator+() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator+ ( ) const
inlinenoexcept

Definition at line 257 of file Types.h.

258  {
259  return Int2(*this);
260  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator+=()

DLLEXPORT Int2& Leviathan::Int2::operator+= ( const Int2 other)
inlinenoexcept

Definition at line 230 of file Types.h.

231  {
232  X += other.X;
233  Y += other.Y;
234  return *this;
235  }

◆ operator-() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator- ( const Int2 other) const
inlinenoexcept

Definition at line 238 of file Types.h.

239  {
240  return Int2(X - other.X, Y - other.Y);
241  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator-() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator- ( ) const
inlinenoexcept

Definition at line 251 of file Types.h.

252  {
253  return Int2(-X, -Y);
254  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator-=()

DLLEXPORT Int2& Leviathan::Int2::operator-= ( const Int2 other)
inlinenoexcept

Definition at line 243 of file Types.h.

244  {
245  X -= other.X;
246  Y -= other.Y;
247  return *this;
248  }

◆ operator/() [1/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator/ ( int  val) const
inline

Definition at line 276 of file Types.h.

277  {
278  return Int2(X / val, Y / val);
279  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator/() [2/2]

DLLEXPORT constexpr Int2 Leviathan::Int2::operator/ ( const Int2 other) const
inline

Definition at line 302 of file Types.h.

303  {
304  return Int2(X / other.X, Y / other.Y);
305  }
DLLEXPORT constexpr Int2() noexcept=default

◆ operator/=() [1/2]

DLLEXPORT Int2& Leviathan::Int2::operator/= ( int  val)
inline

Definition at line 281 of file Types.h.

282  {
283  X /= val;
284  Y /= val;
285  return *this;
286  }

◆ operator/=() [2/2]

DLLEXPORT Int2& Leviathan::Int2::operator/= ( const Int2 other)
inline

Definition at line 307 of file Types.h.

308  {
309  X /= other.X;
310  Y /= other.Y;
311  return *this;
312  }

◆ operator<()

DLLEXPORT constexpr bool Leviathan::Int2::operator< ( const Int2 other) const
inlinenoexcept

Definition at line 316 of file Types.h.

317  {
318  return std::tie(X, Y) < std::tie(other.X, other.Y);
319  }

◆ operator<=()

DLLEXPORT constexpr bool Leviathan::Int2::operator<= ( const Int2 other) const
inlinenoexcept

Definition at line 321 of file Types.h.

322  {
323  return std::tie(X, Y) <= std::tie(other.X, other.Y);
324  }

◆ operator==()

DLLEXPORT constexpr bool Leviathan::Int2::operator== ( const Int2 other) const
inlinenoexcept

Definition at line 336 of file Types.h.

337  {
338  return X == other.X && Y == other.Y;
339  }

◆ operator>()

DLLEXPORT constexpr bool Leviathan::Int2::operator> ( const Int2 other) const
inlinenoexcept

Definition at line 326 of file Types.h.

327  {
328  return std::tie(X, Y) > std::tie(other.X, other.Y);
329  }

◆ operator>=()

DLLEXPORT constexpr bool Leviathan::Int2::operator>= ( const Int2 other) const
inlinenoexcept

Definition at line 331 of file Types.h.

332  {
333  return std::tie(X, Y) >= std::tie(other.X, other.Y);
334  }

◆ operator[]()

DLLEXPORT int& Leviathan::Int2::operator[] ( int  nindex)
inline

Definition at line 211 of file Types.h.

212  {
213  switch(nindex) {
214  case 0: return X;
215  case 1: return Y;
216  default: break;
217  }
218 
219  LEVIATHAN_ASSERT(0, "invalid [] access");
220  return X;
221  }
#define LEVIATHAN_ASSERT(x, msg)
Definition: Define.h:100

◆ SetX()

DLLEXPORT void Leviathan::Int2::SetX ( int  val)
inline

Definition at line 359 of file Types.h.

360  {
361  X = val;
362  }

◆ SetY()

DLLEXPORT void Leviathan::Int2::SetY ( int  val)
inline

Definition at line 364 of file Types.h.

365  {
366  Y = val;
367  }

◆ VALUE_TYPE()

Leviathan::Int2::VALUE_TYPE ( Int2  )

Member Data Documentation

◆ X

int Leviathan::Int2::X = 0

Definition at line 414 of file Types.h.

◆ Y

int Leviathan::Int2::Y = 0

Definition at line 415 of file Types.h.


The documentation for this struct was generated from the following file: