Math v0.0.1
float2

Floating point 2 component vector structure. More...

#include <float.hpp>

Public Member Functions

constexpr float2 (float xy=0.0f) noexcept
 Creates a new floating point 2 component vector structure.
 
constexpr float2 (float x, float y) noexcept
 Creates a new floating point 2 component vector structure.
 
constexpr float2 (uint2 xy) noexcept
 Creates a new floating point 2 component vector structure.
 
constexpr float2 (int2 xy) noexcept
 Creates a new floating point 2 component vector structure.
 
float & operator[] (psize i) noexcept
 Returns vector component by index.
 
float 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 int2 () const noexcept
 Returns as 2 component signed integer vector. (xy)
 
constexpr operator uint32 () const noexcept
 Returns first vector component as unsigned integer. (x)
 
constexpr operator int32 () const noexcept
 Returns first vector component as signed integer. (x)
 
constexpr operator float () const noexcept
 Returns first vector component value. (x)
 
constexpr float2 operator+ (float2 v) const noexcept
 
constexpr float2 operator- (float2 v) const noexcept
 
constexpr float2 operator* (float2 v) const noexcept
 
constexpr float2 operator/ (float2 v) const noexcept
 
constexpr float2 operator+ (float n) const noexcept
 
constexpr float2 operator- (float n) const noexcept
 
constexpr float2 operator* (float n) const noexcept
 
constexpr float2 operator/ (float n) const noexcept
 
constexpr float2 operator- () const noexcept
 
float2operator+= (float2 v) noexcept
 
float2operator-= (float2 v) noexcept
 
float2operator*= (float2 v) noexcept
 
float2operator/= (float2 v) noexcept
 
float2operator+= (float n) noexcept
 
float2operator-= (float n) noexcept
 
float2operator*= (float n) noexcept
 
float2operator/= (float n) noexcept
 
float2operator= (float n) noexcept
 
constexpr bool operator== (float2 v) const noexcept
 
constexpr bool operator!= (float2 v) const noexcept
 
constexpr uint2 operator< (float2 v) const noexcept
 
constexpr uint2 operator> (float2 v) const noexcept
 
constexpr uint2 operator<= (float2 v) const noexcept
 
constexpr uint2 operator>= (float2 v) const noexcept
 
constexpr bool operator== (float n) const noexcept
 
constexpr bool operator!= (float n) const noexcept
 
constexpr uint2 operator< (float n) const noexcept
 
constexpr uint2 operator> (float n) const noexcept
 
constexpr uint2 operator<= (float n) const noexcept
 
constexpr uint2 operator>= (float n) const noexcept
 

Public Attributes

float x
 
float y
 

Static Public Attributes

static const float2 zero = float2(0.0f)
 
static const float2 one = float2(1.0f)
 
static const float2 minusOne = float2(-1.0f)
 
static const float2 min = float2(FLT_MIN)
 
static const float2 minusMin = float2(-FLT_MIN)
 
static const float2 max = float2(FLT_MAX)
 
static const float2 minusMax = float2(-FLT_MAX)
 
static const float2 epsilon = float2(FLT_EPSILON)
 
static const float2 inf = float2(INFINITY)
 
static const float2 minusInf = float2(-INFINITY)
 
static const float2 nan = float2(NAN)
 
static const float2 left = float2(-1.0f, 0.0f)
 
static const float2 right = float2(1.0f, 0.0f)
 
static const float2 bottom = float2(0.0f, -1.0f)
 
static const float2 top = float2(0.0f, 1.0f)
 

Detailed Description

Floating point 2 component vector structure.

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

Constructor & Destructor Documentation

◆ float2() [1/4]

constexpr float2 ( float xy = 0.0f)
inlineexplicitconstexprnoexcept

Creates a new floating point 2 component vector structure.

Parameters
xytarget value for all vector components

◆ float2() [2/4]

constexpr float2 ( float x,
float y )
inlineconstexprnoexcept

Creates a new floating point 2 component vector structure.

Parameters
xfirst vector component value
ysecond vector component value

◆ float2() [3/4]

constexpr float2 ( uint2 xy)
inlineconstexprnoexcept

Creates a new floating point 2 component vector structure.

Parameters
xytarget unsigned integer vector value

◆ float2() [4/4]

constexpr float2 ( int2 xy)
inlineconstexprnoexcept

Creates a new floating point 2 component vector structure.

Parameters
xytarget signed integer vector value

Member Function Documentation

◆ operator[]() [1/2]

float & operator[] ( psize i)
inlinenoexcept

Returns vector component by index.

Parameters
itarget component index

◆ operator[]() [2/2]

float operator[] ( psize i) const
inlinenoexcept

Returns vector component by index.

Parameters
itarget component index

Member Data Documentation

◆ x

float x

First vector component.

◆ y

float y

Second vector component.