86 template<
typename T> T
as()
const;
118 return (this->
x == rhs.
x) && (this->
y == rhs.
y);
127 return (this->
x != rhs.
x) || (this->
y != rhs.
y);
136 return vec2(-this->
x, -this->
y);
145 return vec2(this->
x * t, this->
y * t);
184 return vec2(this->
x + rhs.
x, this->y + rhs.
y);
193 return vec2(this->
x - rhs.
x, this->y - rhs.
y);
241 return this->
x * this->
x + this->
y * this->
y;
259 return (this->
x != 0.0f) || (this->
y != 0.0f);
268 return (this->
x != 0.0f) && (this->
y != 0.0f);
278 res.
x = (v0.
x < v1.
x) ? 1.0f : 0.0f;
279 res.
y = (v0.
y < v1.
y) ? 1.0f : 0.0f;
290 res.
x = (v0.
x <= v1.
x) ? 1.0f : 0.0f;
291 res.
y = (v0.
y <= v1.
y) ? 1.0f : 0.0f;
302 res.
x = (v0.
x > v1.
x) ? 1.0f : 0.0f;
303 res.
y = (v0.
y > v1.
y) ? 1.0f : 0.0f;
314 res.
x = (v0.
x >= v1.
x) ? 1.0f : 0.0f;
315 res.
y = (v0.
y >= v1.
y) ? 1.0f : 0.0f;
328 return vec2(v.
x / l, v.
y / l);
332 return vec2(1.0f, 0.0f);
343 return vec2(v0.
x * v1.
x, v0.
y * v1.
y);
352 return vec2(v0.
x / v1.
x, v0.
y / v1.
y);
379 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:606
__forceinline TYPE min(TYPE a, TYPE b)
Definition scalar.h:399
float scalar
Definition scalar.h:45
__forceinline TYPE max(TYPE a, TYPE b)
Definition scalar.h:368
__forceinline scalar abs(scalar a)
Definition scalar.h:441
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:116
void set(scalar x, scalar y)
set content
Definition vec2.h:200
bool any() const
return true if any components are non-zero
Definition vec2.h:257
static vec2 ge(const vec2 &v0, const vec2 &v1)
set greater-or-equal components to non-zero
Definition vec2.h:311
void store(scalar *ptr) const
write content memory
Definition vec2.h:220
static vec2 lt(const vec2 &v0, const vec2 &v1)
set less-then components to non-zero
Definition vec2.h:275
static vec2 minimize(const vec2 &v0, const vec2 &v1)
return vector made up of smallest components of 2 vectors
Definition vec2.h:368
bool operator!=(const vec2 &rhs) const
inequality operator
Definition vec2.h:125
scalar lengthsq() const
return squared length of vector
Definition vec2.h:239
void operator*=(scalar s)
inplace scalar multiply
Definition vec2.h:172
void load(const scalar *ptr)
load content from memory
Definition vec2.h:210
void operator+=(const vec2 &rhs)
inplace add
Definition vec2.h:152
static vec2 multiply(const vec2 &v0, const vec2 &v1)
component wise multiplication
Definition vec2.h:341
vec2 operator+(const vec2 &rhs) const
add 2 vectors
Definition vec2.h:182
vec2 operator-() const
flip sign
Definition vec2.h:134
vec2 operator*(scalar s) const
multiply with scalar
Definition vec2.h:143
scalar x
Definition vec2.h:88
static vec2 maximize(const vec2 &v0, const vec2 &v1)
return vector made up of largest components of 2 vectors
Definition vec2.h:359
vec2()=default
default constructor, NOTE: does NOT setup components!
bool all() const
return true if all components are non-zero
Definition vec2.h:266
static vec2 normalize(const vec2 &v)
return normalized version of vector
Definition vec2.h:323
vec2(const vec2 &rhs)=default
copy constructor
static vec2 divide(const vec2 &v0, const vec2 &v1)
component wise division
Definition vec2.h:350
vec2 abs() const
return component-wise absolute
Definition vec2.h:248
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:299
static vec2 le(const vec2 &v0, const vec2 &v1)
set less-or-equal components to non-zero
Definition vec2.h:287
void operator-=(const vec2 &rhs)
inplace sub
Definition vec2.h:162
scalar y
Definition vec2.h:89
scalar length() const
return length of vector
Definition vec2.h:230