Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
vec2 Struct Reference

two dimensional Cartesian vector object More...

#include <geom.h>

Public Member Functions

 vec2 (float x, float y)
 
 vec2 (const vec &v)
 
 vec2 (const vec4< float > &v)
 
float & operator[] (int i)
 
float operator[] (int i) const
 
bool operator== (const vec2 &o) const
 
bool operator!= (const vec2 &o) const
 
const float * data () const
 
bool iszero () const
 
float dot (const vec2 &o) const
 
float squaredlen () const
 
float magnitude () const
 
vec2normalize ()
 
vec2safenormalize ()
 
float cross (const vec2 &o) const
 
float squaredist (const vec2 &e) const
 
float dist (const vec2 &e) const
 
vec2mul (float f)
 
vec2mul (const vec2 &o)
 
vec2square ()
 
vec2div (float f)
 
vec2div (const vec2 &o)
 
vec2recip ()
 
vec2add (float f)
 
vec2add (const vec2 &o)
 
vec2sub (float f)
 
vec2sub (const vec2 &o)
 
vec2neg ()
 
vec2min (const vec2 &o)
 
vec2max (const vec2 &o)
 
vec2min (float f)
 
vec2max (float f)
 
vec2abs ()
 
vec2clamp (float l, float h)
 
vec2reflect (const vec2 &n)
 
vec2lerp (const vec2 &b, float t)
 Linearly interpolates between another vec2 according to scale t.
 
vec2lerp (const vec2 &a, const vec2 &b, float t)
 Linearly interpolates between two other vec2s according to scale t.
 
vec2avg (const vec2 &b)
 
vec2 operator+ (const vec2 &v2) const
 
vec2 operator- (const vec2 &v2) const
 
vec2 operator- () const
 
template<typename T>
vec2 operator* (const T &n)
 
vec2 operator* (const vec2 &v2)
 
template<typename T>
vec2 operator/ (const T &n)
 
vec2 operator/ (const vec2 &v2)
 
template<class B>
vec2madd (const vec2 &a, const B &b)
 
template<class B>
vec2msub (const vec2 &a, const B &b)
 
vec2rotate_around_z (float c, float s)
 
vec2rotate_around_z (float angle)
 
vec2rotate_around_z (const vec2 &sc)
 

Public Attributes

float x
 
float y
 

Detailed Description

two dimensional Cartesian vector object

This object represents a two-dimensional location or vector in Cartesian space, consisting of the x and y axes. Many operators and utility functions corresponding to operations on the 2D plane are defined.

Member Function Documentation

◆ lerp() [1/2]

vec2 & vec2::lerp ( const vec2 & a,
const vec2 & b,
float t )
inline

Linearly interpolates between two other vec2s according to scale t.

If 0 < t < 1 then the matrix will be t% of the way between this and to. Values outside 0..1 imply a linear extrapolation.

Parameters
athe first vec2 to interpolate from
bthe other vec2 to interpolate between
tthe interpolation factor

◆ lerp() [2/2]

vec2 & vec2::lerp ( const vec2 & b,
float t )
inline

Linearly interpolates between another vec2 according to scale t.

If 0 < t < 1 then the matrix will be t% of the way between this and to. Values outside 0..1 imply a linear extrapolation.

Parameters
bthe other vec2 to interpolate between
tthe interpolation factor

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