84 template<
typename T> T
as()
const;
116 return (this->
x == rhs.
x) && (this->
y == rhs.
y);
125 return (this->
x != rhs.
x) || (this->
y != rhs.
y);
134 return vec2(-this->
x, -this->
y);
143 return vec2(this->
x * t, this->
y * t);
182 return vec2(this->
x + rhs.
x, this->y + rhs.
y);
191 return vec2(this->
x - rhs.
x, this->y - rhs.
y);
239 return this->
x * this->
x + this->
y * this->
y;
257 return (this->
x != 0.0f) || (this->
y != 0.0f);
266 return (this->
x != 0.0f) && (this->
y != 0.0f);
276 res.
x = (v0.
x < v1.
x) ? 1.0f : 0.0f;
277 res.
y = (v0.
y < v1.
y) ? 1.0f : 0.0f;
288 res.
x = (v0.
x <= v1.
x) ? 1.0f : 0.0f;
289 res.
y = (v0.
y <= v1.
y) ? 1.0f : 0.0f;
300 res.
x = (v0.
x > v1.
x) ? 1.0f : 0.0f;
301 res.
y = (v0.
y > v1.
y) ? 1.0f : 0.0f;
312 res.
x = (v0.
x >= v1.
x) ? 1.0f : 0.0f;
313 res.
y = (v0.
y >= v1.
y) ? 1.0f : 0.0f;
326 return vec2(v.
x / l, v.
y / l);
330 return vec2(1.0f, 0.0f);
341 return vec2(v0.
x * v1.
x, v0.
y * v1.
y);
368 return v0 + ((v1 - v0) * s);
Different curves.
Definition angularpfeedbackloop.h:17
__forceinline scalar sqrt(scalar x)
Definition scalar.h:236
__forceinline float lerp(float x, float y, float l)
Linearly interpolate between 2 values: ret = x + l * (y - x)
Definition scalar.h:597
__forceinline TYPE min(TYPE a, TYPE b)
Definition scalar.h:390
float scalar
Definition scalar.h:45
__forceinline TYPE max(TYPE a, TYPE b)
Definition scalar.h:359
__forceinline scalar abs(scalar a)
Definition scalar.h:432
Nebula's scalar datatype.
A 2-component float vector class.
Definition vec2.h:21
bool operator==(const vec2 &rhs) const
equality operator
Definition vec2.h:114
void set(scalar x, scalar y)
set content
Definition vec2.h:198
bool any() const
return true if any components are non-zero
Definition vec2.h:255
static vec2 ge(const vec2 &v0, const vec2 &v1)
set greater-or-equal components to non-zero
Definition vec2.h:309
void store(scalar *ptr) const
write content memory
Definition vec2.h:218
static vec2 lt(const vec2 &v0, const vec2 &v1)
set less-then components to non-zero
Definition vec2.h:273
static vec2 minimize(const vec2 &v0, const vec2 &v1)
return vector made up of smallest components of 2 vectors
Definition vec2.h:357
bool operator!=(const vec2 &rhs) const
inequality operator
Definition vec2.h:123
scalar lengthsq() const
return squared length of vector
Definition vec2.h:237
void operator*=(scalar s)
inplace scalar multiply
Definition vec2.h:170
void load(const scalar *ptr)
load content from memory
Definition vec2.h:208
void operator+=(const vec2 &rhs)
inplace add
Definition vec2.h:150
static vec2 multiply(const vec2 &v0, const vec2 &v1)
component wise multiplication
Definition vec2.h:339
vec2 operator+(const vec2 &rhs) const
add 2 vectors
Definition vec2.h:180
vec2 operator-() const
flip sign
Definition vec2.h:132
vec2 operator*(scalar s) const
multiply with scalar
Definition vec2.h:141
scalar x
Definition vec2.h:86
static vec2 maximize(const vec2 &v0, const vec2 &v1)
return vector made up of largest components of 2 vectors
Definition vec2.h:348
vec2()=default
default constructor, NOTE: does NOT setup components!
bool all() const
return true if all components are non-zero
Definition vec2.h:264
static vec2 normalize(const vec2 &v)
return normalized version of vector
Definition vec2.h:321
vec2(const vec2 &rhs)=default
copy constructor
vec2 abs() const
return component-wise absolute
Definition vec2.h:246
T as() const
convert to anything
static vec2 gt(const vec2 &v0, const vec2 &v1)
set greater-then components to non-zero
Definition vec2.h:297
static vec2 le(const vec2 &v0, const vec2 &v1)
set less-or-equal components to non-zero
Definition vec2.h:285
void operator-=(const vec2 &rhs)
inplace sub
Definition vec2.h:160
scalar y
Definition vec2.h:87
scalar length() const
return length of vector
Definition vec2.h:228