Nebula
Loading...
Searching...
No Matches
Math::vec2 Struct Reference

#include <vec2.h>

Detailed Description

A 2-component float vector class.

Public Member Functions

 vec2 ()=default
 default constructor, NOTE: does NOT setup components!
 
 vec2 (scalar x)
 construct from single value
 
 vec2 (scalar x, scalar y)
 construct from values
 
 vec2 (const vec2 &rhs)=default
 copy constructor
 
vec2 operator- () const
 flip sign
 
void operator+= (const vec2 &rhs)
 inplace add
 
void operator-= (const vec2 &rhs)
 inplace sub
 
void operator*= (scalar s)
 inplace scalar multiply
 
vec2 operator+ (const vec2 &rhs) const
 add 2 vectors
 
vec2 operator- (const vec2 &rhs) const
 subtract 2 vectors
 
vec2 operator* (scalar s) const
 multiply with scalar
 
bool operator== (const vec2 &rhs) const
 equality operator
 
bool operator!= (const vec2 &rhs) const
 inequality operator
 
void set (scalar x, scalar y)
 set content
 
void load (const scalar *ptr)
 load content from memory
 
void store (scalar *ptr) const
 write content memory
 
scalar length () const
 return length of vector
 
scalar lengthsq () const
 return squared length of vector
 
vec2 abs () const
 return component-wise absolute
 
bool any () const
 return true if any components are non-zero
 
bool all () const
 return true if all components are non-zero
 
template<typename T >
as () const
 convert to anything
 

Static Public Member Functions

static vec2 multiply (const vec2 &v0, const vec2 &v1)
 component wise multiplication
 
static vec2 maximize (const vec2 &v0, const vec2 &v1)
 return vector made up of largest components of 2 vectors
 
static vec2 minimize (const vec2 &v0, const vec2 &v1)
 return vector made up of smallest components of 2 vectors
 
static vec2 normalize (const vec2 &v)
 return normalized version of vector
 
static vec2 lt (const vec2 &v0, const vec2 &v1)
 set less-then components to non-zero
 
static vec2 le (const vec2 &v0, const vec2 &v1)
 set less-or-equal components to non-zero
 
static vec2 gt (const vec2 &v0, const vec2 &v1)
 set greater-then components to non-zero
 
static vec2 ge (const vec2 &v0, const vec2 &v1)
 set greater-or-equal components to non-zero
 

Public Attributes

scalar x
 
scalar y
 

Constructor & Destructor Documentation

◆ vec2() [1/4]

Math::vec2::vec2 ( )
default

default constructor, NOTE: does NOT setup components!

◆ vec2() [2/4]

Math::vec2::vec2 ( scalar x)
inline

construct from single value

◆ vec2() [3/4]

Math::vec2::vec2 ( scalar x,
scalar y )
inline

construct from values

◆ vec2() [4/4]

Math::vec2::vec2 ( const vec2 & rhs)
default

copy constructor

Member Function Documentation

◆ abs()

vec2 Math::vec2::abs ( ) const
inline

return component-wise absolute

◆ all()

bool Math::vec2::all ( ) const
inline

return true if all components are non-zero

◆ any()

bool Math::vec2::any ( ) const
inline

return true if any components are non-zero

◆ as()

template<typename T >
T Math::vec2::as ( ) const

convert to anything

◆ ge()

vec2 Math::vec2::ge ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

set greater-or-equal components to non-zero

◆ gt()

vec2 Math::vec2::gt ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

set greater-then components to non-zero

◆ le()

vec2 Math::vec2::le ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

set less-or-equal components to non-zero

◆ length()

scalar Math::vec2::length ( ) const
inline

return length of vector

◆ lengthsq()

scalar Math::vec2::lengthsq ( ) const
inline

return squared length of vector

◆ load()

void Math::vec2::load ( const scalar * ptr)
inline

load content from memory

◆ lt()

vec2 Math::vec2::lt ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

set less-then components to non-zero

◆ maximize()

vec2 Math::vec2::maximize ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

return vector made up of largest components of 2 vectors

◆ minimize()

vec2 Math::vec2::minimize ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

return vector made up of smallest components of 2 vectors

◆ multiply()

vec2 Math::vec2::multiply ( const vec2 & v0,
const vec2 & v1 )
inlinestatic

component wise multiplication

◆ normalize()

vec2 Math::vec2::normalize ( const vec2 & v)
inlinestatic

return normalized version of vector

◆ operator!=()

bool Math::vec2::operator!= ( const vec2 & rhs) const
inline

inequality operator

◆ operator*()

vec2 Math::vec2::operator* ( scalar s) const
inline

multiply with scalar

◆ operator*=()

void Math::vec2::operator*= ( scalar s)
inline

inplace scalar multiply

◆ operator+()

vec2 Math::vec2::operator+ ( const vec2 & rhs) const
inline

add 2 vectors

◆ operator+=()

void Math::vec2::operator+= ( const vec2 & rhs)
inline

inplace add

◆ operator-() [1/2]

vec2 Math::vec2::operator- ( ) const
inline

flip sign

◆ operator-() [2/2]

vec2 Math::vec2::operator- ( const vec2 & rhs) const
inline

subtract 2 vectors

◆ operator-=()

void Math::vec2::operator-= ( const vec2 & rhs)
inline

inplace sub

◆ operator==()

bool Math::vec2::operator== ( const vec2 & rhs) const
inline

equality operator

◆ set()

void Math::vec2::set ( scalar x,
scalar y )
inline

set content

◆ store()

void Math::vec2::store ( scalar * ptr) const
inline

write content memory

Member Data Documentation

◆ x

scalar Math::vec2::x

◆ y

scalar Math::vec2::y

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