88 float c = std::cos(
angle);
101 return a.
x * b.
x + a.
y * b.
y;
106 return std::sqrt(
dot(a, a));
111 return std::sqrt(
dot(a, a));
121 if(a.
x == 0 && a.
y == 0)
124 return a.
y < 0 ? -
pi / 2 :
pi / 2;
125 float result = std::atan(a.
y / a.
x);
127 result = result +
pi;
141 float divisor =
length(v);
144 float l = (float)(1.0f / divisor);
166 T SquaredMagnitudeAB =
dot(AB, AB);
167 if(SquaredMagnitudeAB > 0)
170 T APdotAB =
dot(AP, AB);
171 T t = APdotAB / SquaredMagnitudeAB;
172 out_pos = line_pointA + AB * clamp(t, (T)0, (T)1);
267 return a.
x * b.
x + a.
y * b.
y + a.
z * b.
z;
274 a.
y * b.
z - a.
z * b.
y,
275 a.
z * b.
x - a.
x * b.
z,
276 a.
x * b.
y - a.
y * b.
x);
282 return std::sqrt(
dot(a, a));
287 float divisor =
length(v);
290 float l = (float)(1.0f / divisor);
323 x(nx),
y(ny),
z(nz),
w(nw)
T x
Definition: vmath.h:19
vector2_base operator-() const
Definition: vmath.h:32
bool operator==(const vector2_base &vec) const
Definition: vmath.h:77
constexpr vector2_base(T nx, T ny)
Definition: vmath.h:27
T & operator[](const int index)
Definition: vmath.h:80
T y
Definition: vmath.h:23
vector2_base operator*(const vector2_base &vec) const
Definition: vmath.h:36
vector2_base operator/(const vector2_base &vec) const
Definition: vmath.h:38
const vector2_base & operator/=(const T rhs)
Definition: vmath.h:64
T u
Definition: vmath.h:19
vector2_base operator/(const T rhs) const
Definition: vmath.h:37
constexpr vector2_base()=default
const vector2_base & operator/=(const vector2_base &vec)
Definition: vmath.h:70
const vector2_base & operator*=(const vector2_base &vec)
Definition: vmath.h:58
vector2_base operator+(const vector2_base &vec) const
Definition: vmath.h:34
T v
Definition: vmath.h:23
vector2_base operator-(const vector2_base &vec) const
Definition: vmath.h:33
const vector2_base & operator+=(const vector2_base &vec)
Definition: vmath.h:40
bool operator!=(const vector2_base &vec) const
Definition: vmath.h:78
const vector2_base & operator*=(const T rhs)
Definition: vmath.h:52
vector2_base operator*(const T rhs) const
Definition: vmath.h:35
const vector2_base & operator-=(const vector2_base &vec)
Definition: vmath.h:46
T z
Definition: vmath.h:194
constexpr vector3_base()=default
bool operator!=(const vector3_base &vec) const
Definition: vmath.h:255
T x
Definition: vmath.h:186
bool operator==(const vector3_base &vec) const
Definition: vmath.h:254
vector3_base operator/(const vector3_base &vec) const
Definition: vmath.h:209
vector3_base operator/(const T rhs) const
Definition: vmath.h:208
const vector3_base & operator-=(const vector3_base &vec)
Definition: vmath.h:218
T y
Definition: vmath.h:190
const vector3_base & operator/=(const T rhs)
Definition: vmath.h:239
const vector3_base & operator+=(const vector3_base &vec)
Definition: vmath.h:211
const vector3_base & operator/=(const vector3_base &vec)
Definition: vmath.h:246
T s
Definition: vmath.h:190
T v
Definition: vmath.h:190
T r
Definition: vmath.h:186
vector3_base operator-() const
Definition: vmath.h:204
T g
Definition: vmath.h:190
const vector3_base & operator*=(const T rhs)
Definition: vmath.h:225
vector3_base operator+(const vector3_base &vec) const
Definition: vmath.h:205
T u
Definition: vmath.h:186
vector3_base operator-(const vector3_base &vec) const
Definition: vmath.h:203
T w
Definition: vmath.h:194
const vector3_base & operator*=(const vector3_base &vec)
Definition: vmath.h:232
T b
Definition: vmath.h:194
T h
Definition: vmath.h:186
vector3_base operator*(const T rhs) const
Definition: vmath.h:206
vector3_base operator*(const vector3_base &vec) const
Definition: vmath.h:207
T l
Definition: vmath.h:194
constexpr vector3_base(T nx, T ny, T nz)
Definition: vmath.h:198
T g
Definition: vmath.h:310
T w
Definition: vmath.h:318
vector4_base operator+(const vector4_base &vec) const
Definition: vmath.h:327
const vector4_base & operator-=(const vector4_base &vec)
Definition: vmath.h:343
T b
Definition: vmath.h:314
T s
Definition: vmath.h:310
T r
Definition: vmath.h:306
T h
Definition: vmath.h:306
const vector4_base & operator/=(const T rhs)
Definition: vmath.h:367
T z
Definition: vmath.h:314
const vector4_base & operator+=(const vector4_base &vec)
Definition: vmath.h:335
vector4_base operator/(const T vec) const
Definition: vmath.h:333
vector4_base operator*(const vector4_base &vec) const
Definition: vmath.h:330
const vector4_base & operator*=(const T rhs)
Definition: vmath.h:351
constexpr vector4_base(T nx, T ny, T nz, T nw)
Definition: vmath.h:322
vector4_base operator*(const T rhs) const
Definition: vmath.h:331
T y
Definition: vmath.h:310
vector4_base operator/(const vector4_base &vec) const
Definition: vmath.h:332
vector4_base operator-(const vector4_base &vec) const
Definition: vmath.h:328
bool operator!=(const vector4_base &vec) const
Definition: vmath.h:385
T l
Definition: vmath.h:314
const vector4_base & operator*=(const vector4_base &vec)
Definition: vmath.h:359
constexpr vector4_base()=default
vector4_base operator-() const
Definition: vmath.h:329
T a
Definition: vmath.h:318
bool operator==(const vector4_base &vec) const
Definition: vmath.h:384
T x
Definition: vmath.h:306
const vector4_base & operator/=(const vector4_base &vec)
Definition: vmath.h:375
static SHA256_DIGEST s(const char *pSha256)
Definition: mapbugs.cpp:37
constexpr float pi
Definition: math.h:12
float random_angle()
Definition: math.h:74
vector4_base< int > ivec4
Definition: vmath.h:390
constexpr float angle(const vector2_base< float > &a)
Definition: vmath.h:119
vector2_base< float > normalize(const vector2_base< float > &v)
Definition: vmath.h:139
float length(const vector2_base< float > &a)
Definition: vmath.h:104
vector4_base< uint8_t > ubvec4
Definition: vmath.h:391
constexpr vector3_base< T > cross(const vector3_base< T > &a, const vector3_base< T > &b)
Definition: vmath.h:271
vector2_base< float > direction(float angle)
Definition: vmath.h:148
vector4_base< bool > bvec4
Definition: vmath.h:389
vector3_base< float > vec3
Definition: vmath.h:294
vector4_base< float > vec4
Definition: vmath.h:388
vector2_base< int > ivec2
Definition: vmath.h:160
vector3_base< int > ivec3
Definition: vmath.h:296
float length_squared(const vector2_base< float > &a)
Definition: vmath.h:114
vector2_base< bool > bvec2
Definition: vmath.h:159
vector2_base< float > random_direction()
Definition: vmath.h:153
vector3_base< bool > bvec3
Definition: vmath.h:295
constexpr vector2_base< T > rotate(const vector2_base< T > &a, float angle)
Definition: vmath.h:84
vector2_base< float > vec2
Definition: vmath.h:158
constexpr vector2_base< T > normalize_pre_length(const vector2_base< T > &v, T len)
Definition: vmath.h:132
constexpr bool closest_point_on_line(vector2_base< T > line_pointA, vector2_base< T > line_pointB, vector2_base< T > target_point, vector2_base< T > &out_pos)
Definition: vmath.h:163
constexpr T dot(const vector2_base< T > a, const vector2_base< T > &b)
Definition: vmath.h:99
T distance(const vector2_base< T > a, const vector2_base< T > &b)
Definition: vmath.h:93