Math v0.0.1
int2

Signed integer 2 component vector structure. More...

#include <int.hpp>

Public Member Functions

constexpr int2 (int32 xy=0) noexcept
 Creates a new signed integer 2 component vector structure.
 
constexpr int2 (int32 x, int32 y) noexcept
 Creates a new signed integer 2 component vector structure.
 
constexpr int2 (uint2 xy) noexcept
 Creates a new signed integer 2 component vector structure.
 
int32operator[] (psize i) noexcept
 Returns vector component by index.
 
int32 operator[] (psize i) const noexcept
 Returns vector component by index.
 
constexpr operator uint2 () const noexcept
 Returns as 2 component unsigned integer vector. (xy)
 
constexpr operator uint32 () noexcept
 Returns first vector component as unsigned integer value. (x)
 
constexpr operator int32 () noexcept
 Returns first vector component value. (x)
 
constexpr int2 operator+ (int2 v) const noexcept
 
constexpr int2 operator- (int2 v) const noexcept
 
constexpr int2 operator* (int2 v) const noexcept
 
constexpr int2 operator/ (int2 v) const noexcept
 
constexpr int2 operator% (int2 v) const noexcept
 
constexpr int2 operator& (int2 v) const noexcept
 
constexpr int2 operator| (int2 v) const noexcept
 
constexpr int2 operator^ (int2 v) const noexcept
 
constexpr int2 operator>> (int2 v) const noexcept
 
constexpr int2 operator<< (int2 v) const noexcept
 
constexpr int2 operator+ (int32 n) const noexcept
 
constexpr int2 operator- (int32 n) const noexcept
 
constexpr int2 operator* (int32 n) const noexcept
 
constexpr int2 operator/ (int32 n) const noexcept
 
constexpr int2 operator% (int32 n) const noexcept
 
constexpr int2 operator& (int32 n) const noexcept
 
constexpr int2 operator| (int32 n) const noexcept
 
constexpr int2 operator^ (int32 n) const noexcept
 
constexpr int2 operator>> (int32 n) const noexcept
 
constexpr int2 operator<< (int32 n) const noexcept
 
constexpr int2 operator- () const noexcept
 
constexpr int2 operator! () const noexcept
 
constexpr int2 operator~ () const noexcept
 
int2operator+= (int2 v) noexcept
 
int2operator-= (int2 v) noexcept
 
int2operator*= (int2 v) noexcept
 
int2operator/= (int2 v) noexcept
 
int2operator%= (int2 v) noexcept
 
int2operator&= (int2 v) noexcept
 
int2operator|= (int2 v) noexcept
 
int2operator^= (int2 v) noexcept
 
int2operator>>= (int2 v) noexcept
 
int2operator<<= (int2 v) noexcept
 
int2operator+= (int32 n) noexcept
 
int2operator-= (int32 n) noexcept
 
int2operator*= (int32 n) noexcept
 
int2operator/= (int32 n) noexcept
 
int2operator%= (int32 n) noexcept
 
int2operator&= (int32 n) noexcept
 
int2operator|= (int32 n) noexcept
 
int2operator^= (int32 n) noexcept
 
int2operator>>= (int32 n) noexcept
 
int2operator<<= (int32 n) noexcept
 
int2operator= (int32 n) noexcept
 
constexpr bool operator== (int2 v) const noexcept
 
constexpr bool operator!= (int2 v) const noexcept
 
constexpr uint2 operator< (int2 v) const noexcept
 
constexpr uint2 operator> (int2 v) const noexcept
 
constexpr uint2 operator<= (int2 v) const noexcept
 
constexpr uint2 operator>= (int2 v) const noexcept
 
constexpr bool operator== (int32 n) const noexcept
 
constexpr bool operator!= (int32 n) const noexcept
 
constexpr uint2 operator< (int32 n) const noexcept
 
constexpr uint2 operator> (int32 n) const noexcept
 
constexpr uint2 operator<= (int32 n) const noexcept
 
constexpr uint2 operator>= (int32 n) const noexcept
 

Public Attributes

int32 x
 
int32 y
 

Static Public Attributes

static const int2 zero = int2(0)
 
static const int2 one = int2(1)
 
static const int2 minusOne = int2(-1)
 
static const int2 left = int2(-1, 0)
 
static const int2 right = int2(1, 0)
 
static const int2 bottom = int2(0, -1)
 
static const int2 top = int2(0, 1)
 

Detailed Description

Signed integer 2 component vector structure.

Commonly used to represent: points, positions, directions, velocities, etc.

Constructor & Destructor Documentation

◆ int2() [1/3]

constexpr int2 ( int32 xy = 0)
inlineexplicitconstexprnoexcept

Creates a new signed integer 2 component vector structure.

Parameters
xytarget value for all vector components

◆ int2() [2/3]

constexpr int2 ( int32 x,
int32 y )
inlineconstexprnoexcept

Creates a new signed integer 2 component vector structure.

Parameters
xfirst vector component value
ysecond vector component value

◆ int2() [3/3]

constexpr int2 ( uint2 xy)
inlineconstexprnoexcept

Creates a new signed integer 2 component vector structure.

Parameters
xytarget unsigned integer vector value

Member Function Documentation

◆ operator[]() [1/2]

int32 & operator[] ( psize i)
inlinenoexcept

Returns vector component by index.

Parameters
itarget component index

◆ operator[]() [2/2]

int32 operator[] ( psize i) const
inlinenoexcept

Returns vector component by index.

Parameters
itarget component index

Member Data Documentation

◆ x

int32 x

First vector component.

◆ y

int32 y

Second vector component.