2
3
4
5
6
7
8
9
10
11
12
13
14
33
34
35
36
37
38
39
40
41
42template<
typename CRTP,
typename C, size_t R>
47 static constexpr size_t
Rows = R;
48 static constexpr size_t
Cols = 1;
57 SHZ_FORCE_INLINE
vecN(
const CType& other)
noexcept:
61 SHZ_FORCE_INLINE
vecN(
const volatile CType& other)
noexcept:
62 CType(
const_cast<
const CType&>(other)) {}
65 SHZ_FORCE_INLINE
static CppType
from(
const auto& raw)
noexcept {
66 return *
reinterpret_cast<
const CppType*>(&raw);
71 SHZ_FORCE_INLINE T
to()
const noexcept {
72 return *
reinterpret_cast<
const T*>(
this);
76 SHZ_FORCE_INLINE CppType&
deref(
const auto* raw)
noexcept {
77 return *
const_cast<CppType*>(
reinterpret_cast<
const CppType*>(raw));
81 SHZ_FORCE_INLINE
static CppType
lerp(
const CppType& start,
const CppType& end,
float t)
noexcept {
82 return shz_vec_lerp(start, end, t);
87 SHZ_FORCE_INLINE
static CppType
step(
const CppType& vec, T&& edge)
noexcept {
88 return shz_vec_step(vec, edge);
93 SHZ_FORCE_INLINE
static CppType
smoothstep(
const CppType& vec, T&& edge0, T&& edge1)
noexcept {
94 return shz_vec_smoothstep(vec, edge0, edge1);
99 SHZ_FORCE_INLINE
static CppType
smoothstep_safe(
const CppType& vec, T&& edge0, T&& edge1)
noexcept {
100 return shz_vec_smoothstep_safe(vec, edge0, edge1);
133 friend bool operator==(
const CppType& lhs,
const CppType& rhs)
noexcept {
134 return shz_vec_equal(lhs, rhs);
138 friend CppType
operator-(
const CppType& vec)
noexcept {
143 SHZ_FORCE_INLINE CppType&
operator+=(
const CppType& other)
noexcept {
144 *
static_cast<CppType*>(
this) = *
static_cast<CppType*>(
this) + other;
145 return *
static_cast<CppType*>(
this);
149 SHZ_FORCE_INLINE CppType&
operator-=(
const CppType& other)
noexcept {
150 *
static_cast<CppType*>(
this) = *
static_cast<CppType*>(
this) - other;
151 return *
static_cast<CppType*>(
this);
155 SHZ_FORCE_INLINE CppType&
operator*=(
const CppType& other)
noexcept {
156 *
static_cast<CppType*>(
this) = *
static_cast<CppType*>(
this) * other;
157 return *
static_cast<CppType*>(
this);
161 SHZ_FORCE_INLINE CppType&
operator/=(
const CppType& other)
noexcept {
162 *
static_cast<CppType*>(
this) = *
static_cast<CppType*>(
this) / other;
163 return *
static_cast<CppType*>(
this);
167 SHZ_FORCE_INLINE CppType&
operator*=(
float other)
noexcept {
168 *
static_cast<CppType*>(
this) = *
static_cast<CppType*>(
this) * other;
169 return *
static_cast<CppType*>(
this);
173 SHZ_FORCE_INLINE CppType&
operator/=(
float other)
noexcept {
174 *
static_cast<CppType*>(
this) = *
static_cast<CppType*>(
this) / other;
175 return *
static_cast<CppType*>(
this);
179 template<
unsigned... Indices>
180 SHZ_FORCE_INLINE CppType
swizzle()
const noexcept {
181 return shz_vec_swizzle(*
static_cast<
const CppType*>(
this), Indices...);
185 SHZ_FORCE_INLINE CppType
abs()
const noexcept {
186 return shz_vec_abs(*
static_cast<
const CppType*>(
this));
190 SHZ_FORCE_INLINE CppType
neg()
const noexcept {
191 return shz_vec_neg(*
static_cast<
const CppType*>(
this));
195 SHZ_FORCE_INLINE CppType
inv()
const noexcept {
196 return shz_vec_inv(*
static_cast<
const CppType*>(
this));
200 SHZ_FORCE_INLINE
float max()
const noexcept {
201 return shz_vec_max(*
static_cast<
const CppType*>(
this));
205 SHZ_FORCE_INLINE
float min()
const noexcept {
206 return shz_vec_min(*
static_cast<
const CppType*>(
this));
210 SHZ_FORCE_INLINE CppType
clamp(
float min,
float max)
const noexcept {
211 return shz_vec_clamp(*
static_cast<
const CppType*>(
this), min, max);
215 SHZ_FORCE_INLINE CppType
floor()
const noexcept {
216 return shz_vec_floor(*
static_cast<
const CppType*>(
this));
220 SHZ_FORCE_INLINE CppType
ceil()
const noexcept {
221 return shz_vec_ceil(*
static_cast<
const CppType*>(
this));
225 SHZ_FORCE_INLINE CppType
round()
const noexcept {
226 return shz_vec_round(*
static_cast<
const CppType*>(
this));
230 SHZ_FORCE_INLINE CppType
fract()
const noexcept {
231 return shz_vec_fract(*
static_cast<
const CppType*>(
this));
235 SHZ_FORCE_INLINE CppType
sign()
const noexcept {
236 return shz_vec_sign(*
static_cast<
const CppType*>(
this));
240 SHZ_FORCE_INLINE CppType
saturate()
const noexcept {
241 return shz_vec_saturate(*
static_cast<
const CppType*>(
this));
245 SHZ_FORCE_INLINE CppType
minv(
const CppType& other)
const noexcept {
246 return shz_vec_minv(*
static_cast<
const CppType*>(
this), other);
250 SHZ_FORCE_INLINE CppType
maxv(
const CppType& other)
const noexcept {
251 return shz_vec_maxv(*
static_cast<
const CppType*>(
this), other);
255 SHZ_FORCE_INLINE
float dot(
const CppType& other)
const noexcept {
256 return shz_vec_dot(*
static_cast<
const CppType*>(
this), other);
260 SHZ_FORCE_INLINE
vec2 dot(
const CppType& v1,
const CppType& v2)
const noexcept;
263 SHZ_FORCE_INLINE
vec3 dot(
const CppType& v1,
const CppType& v2,
const CppType& v3)
const noexcept;
267 return shz_vec_magnitude(*
static_cast<
const CppType*>(
this));
272 return shz_vec_magnitude_sqr(*
static_cast<
const CppType*>(
this));
277 return shz_vec_magnitude_inv(*
static_cast<
const CppType*>(
this));
282 return shz_vec_normalize(*
static_cast<
const CppType*>(
this));
287 return shz_vec_normalize_safe(*
static_cast<
const CppType*>(
this));
292 *
static_cast<CppType*>(
this) = shz_vec_normalize(*
static_cast<
const CppType*>(
this));
297 *
static_cast<CppType*>(
this) = shz_vec_normalize_safe(*
static_cast<
const CppType*>(
this));
302 return shz_vec_normalize(*
static_cast<
const CppType*>(
this));
307 return shz_vec_normalize_safe(*
static_cast<
const CppType*>(
this));
311 SHZ_FORCE_INLINE
float distance(
const CppType& other)
const noexcept {
312 return shz_vec_distance(*
static_cast<
const CppType*>(
this), other);
316 SHZ_FORCE_INLINE
float distance_sqr(
const CppType& other)
const noexcept {
317 return shz_vec_distance_sqr(*
static_cast<
const CppType*>(
this), other);
321 SHZ_FORCE_INLINE CppType
move(
const CppType& target,
float maxdist)
const noexcept {
322 return shz_vec_move(*
static_cast<
const CppType*>(
this), target, maxdist);
326 SHZ_FORCE_INLINE CppType
reflect(
const CppType& normal)
const noexcept {
327 return shz_vec_reflect(*
static_cast<
const CppType*>(
this), normal);
331 SHZ_FORCE_INLINE CppType
refract(
const CppType& normal,
float eta)
const noexcept {
332 return shz_vec_refract(*
static_cast<
const CppType*>(
this), normal, eta);
336 SHZ_FORCE_INLINE CppType
project(
const CppType& onto)
const noexcept {
337 return shz_vec_project(*
static_cast<
const CppType*>(
this), onto);
341 SHZ_FORCE_INLINE CppType
project_safe(
const CppType& onto)
const noexcept {
342 return shz_vec_project_safe(*
static_cast<
const CppType*>(
this), onto);
347 return shz_vec_angle_between(*
static_cast<
const CppType*>(
this), other);
351 SHZ_FORCE_INLINE
auto angles()
const noexcept {
352 return shz_vec_angles(*
static_cast<
const CppType*>(
this));
357template<
typename CRTP,
typename C, size_t R>
358SHZ_FORCE_INLINE CRTP
operator+(
const vecN<CRTP, C, R>& lhs,
const vecN<CRTP, C, R>& rhs)
noexcept {
359 return shz_vec_add(lhs, rhs);
363template<
typename CRTP,
typename C, size_t R>
364SHZ_FORCE_INLINE CRTP
operator-(
const vecN<CRTP, C, R>& lhs,
const vecN<CRTP, C, R>& rhs)
noexcept {
365 return shz_vec_sub(lhs, rhs);
369template<
typename CRTP,
typename C, size_t R>
370SHZ_FORCE_INLINE CRTP
operator*(
const vecN<CRTP, C, R>& lhs,
const vecN<CRTP, C, R>& rhs)
noexcept {
371 return shz_vec_mul(lhs, rhs);
375template<
typename CRTP,
typename C, size_t R>
376SHZ_FORCE_INLINE CRTP
operator/(
const vecN<CRTP, C, R>& lhs,
const vecN<CRTP, C, R>& rhs)
noexcept {
377 return shz_vec_div(lhs, rhs);
381template<
typename CRTP,
typename C, size_t R>
382SHZ_FORCE_INLINE CRTP
operator*(
const vecN<CRTP, C, R>& lhs,
float rhs)
noexcept {
383 return shz_vec_scale(lhs, rhs);
387template<
typename CRTP,
typename C, size_t R>
388SHZ_FORCE_INLINE CRTP
operator*(
float lhs,
const vecN<CRTP, C, R>& rhs)
noexcept {
389 return shz_vec_scale(rhs, lhs);
393template<
typename CRTP,
typename C, size_t R>
394SHZ_FORCE_INLINE CRTP
operator/(
const vecN<CRTP, C, R>& lhs,
float rhs)
noexcept {
399template<
typename CRTP,
typename C, size_t R>
400SHZ_FORCE_INLINE CRTP
operator/(
float lhs,
const vecN<CRTP, C, R>& rhs)
noexcept {
401 return shz_vec_div(CRTP(lhs), rhs);
405
406
407
408
409
424 SHZ_FORCE_INLINE
vec2(
float v)
noexcept:
428 SHZ_FORCE_INLINE
vec2(
float x,
float y)
noexcept:
446 SHZ_FORCE_INLINE
float cross(
const vec2& other)
const noexcept {
447 return shz_vec2_cross(*
this, other);
452 return shz_vec2_rotate(*
this, radians);
460
461
462
463
464
479 SHZ_FORCE_INLINE
vec3(
const shz_vec3_t& other)
noexcept:
483 SHZ_FORCE_INLINE
vec3(
float v)
noexcept:
487 SHZ_FORCE_INLINE
vec3(
float x,
float y,
float z)
noexcept:
505 shz_vec3_orthonormalize(in1, in2, &out1, &out2);
506 return std::make_pair(out1, out2);
511 shz_vec3_orthonormalize(in1, in2, out1, out2);
516 return shz_vec3_cubic_hermite(v1, tangent1, v2, tangent2, amount);
520 SHZ_FORCE_INLINE
vec2 xy()
const noexcept {
521 return shz_vec3_t::xy;
525 SHZ_FORCE_INLINE
static vec3 from_angles(
float azimuth_rads,
float elevation_rads)
noexcept {
536 return shz_vec3_cross(*
this, other);
541 return shz_vec3_triple(*
this, b, c);
546 return shz_vec3_perp(*
this);
551 return shz_vec3_reject(*
this, onto);
556 return shz_vec3_barycenter(*
this, a, b, c);
564
565
566
567
568
583 SHZ_FORCE_INLINE
vec4(
const shz_vec4_t& other)
noexcept:
587 SHZ_FORCE_INLINE
vec4(
float v)
noexcept:
591 SHZ_FORCE_INLINE
vec4(
float x,
float y,
float z,
float w)
noexcept:
595 SHZ_FORCE_INLINE
vec4(
const shz::
vec2& xy,
float z,
float w)
noexcept:
599 SHZ_FORCE_INLINE
vec4(
float x,
const shz::
vec2& yz,
float w)
noexcept:
603 SHZ_FORCE_INLINE
vec4(
float x,
float y,
const shz::
vec2& zw)
noexcept:
619 SHZ_FORCE_INLINE
vec2 xy()
const noexcept {
620 return shz_vec4_t::xy;
624 SHZ_FORCE_INLINE
vec2 zw()
const noexcept {
625 return shz_vec4_t::zw;
629 SHZ_FORCE_INLINE
vec3 xyz()
const noexcept {
630 return shz_vec4_t::xyz;
637template<
typename CRTP,
typename C, size_t R>
638SHZ_FORCE_INLINE
vec2 vecN<CRTP, C, R>::
dot(
const CppType& v1,
const CppType& v2)
const noexcept {
639 return shz_vec_dot2(*
static_cast<
const CRTP*>(
this), v1, v2);
642template<
typename CRTP,
typename C, size_t R>
643SHZ_FORCE_INLINE
vec3 vecN<CRTP, C, R>::
dot(
const CppType& v1,
const CppType& v2,
const CppType& v3)
const noexcept {
644 return shz_vec_dot3(*
static_cast<
const CRTP*>(
this), v1, v2, v3);
Namespace enclosing the SH4ZAM C++ API.
CRTP operator+(const vecN< CRTP, C, R > &lhs, const vecN< CRTP, C, R > &rhs) noexcept
Overloaded addition operator, adding two vectors together and returning the result.
CRTP operator*(float lhs, const vecN< CRTP, C, R > &rhs) noexcept
Reverse overloaded multiplication operator for scaling a vector by a scalar and returning the resulti...
CRTP operator-(const vecN< CRTP, C, R > &lhs, const vecN< CRTP, C, R > &rhs) noexcept
Overloaded subtraction operator, subtracting one vector from another, returning the result.
CRTP operator*(const vecN< CRTP, C, R > &lhs, float rhs) noexcept
Overloaded multiplication operator for scaling a vector by a scalar and returning the resulting vecto...
CRTP operator/(const vecN< CRTP, C, R > &lhs, float rhs) noexcept
Overloaded division operator for component-wise dividing each element of the given vector by the give...
CRTP operator/(const vecN< CRTP, C, R > &lhs, const vecN< CRTP, C, R > &rhs) noexcept
Overloaded division operator, returning the resulting vector from component-wise dividing the element...
CRTP operator/(float lhs, const vecN< CRTP, C, R > &rhs) noexcept
Reverse overloaded division operator for component-wise dividing a vector whose elements have all bee...
constexpr auto invf
C++ alias for shz_invf().
CRTP operator*(const vecN< CRTP, C, R > &lhs, const vecN< CRTP, C, R > &rhs) noexcept
Overloaded multiplication operator, performing element-wise multiplication between two vectors,...
shz_vec2_t shz_vec2_from_angle(float radians) SHZ_NOEXCEPT
Returns the 2D unit vector representing a rotation from the positive X axis in radians.
shz_vec2_t shz_vec2_from_angle_deg(float degrees) SHZ_NOEXCEPT
Returns the 2D unit vector representing a rotation from the positive X axis in degrees.
shz_vec3_t shz_vec3_from_angles_deg(float azimuth, float elevation) SHZ_NOEXCEPT
Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in ...
shz_vec3_t shz_vec3_from_angles(float azimuth, float elevation) SHZ_NOEXCEPT
Returns the 3D unit vector representing the given rotation angles relative to the positive X axis in ...
C++ sine/cosine approximation pairs.
vec2(float v) noexcept
Single-value constructor: sets both components equal to v.
vec2()=default
Default constructor: does nothing.
vec2(float x, float y) noexcept
Constructs a vec2 with the given values as components.
vec2(const sincos &pair) noexcept
Constructs a vec2 from the given angle of rotation from the +X axis.
float cross(const vec2 &other) const noexcept
C++ wrapper for shz_vec2_cross().
static vec2 from_angle_deg(float deg) noexcept
Constructs a vec2 from the given angle of rotation from the +X axis, in degrees.
vec2 rotate(float radians) const noexcept
C++ wrapper for shz_vec2_rotate().
static vec2 from_angle(float rads) noexcept
Constructs a vec2 from the given angle of rotation from the +X axis, in radians.
vec3 barycenter(const vec3 &a, const vec3 &b, const vec3 &c) const noexcept
Computes the barycentric coordinates <u, v, w> for the given 3D vector, within the plane of the trian...
vec3 reject(const vec3 &onto) const noexcept
Returns the 3D reject vector of the given vector and another.
vec3(const sincos &azimuth, const sincos &elevation) noexcept
Returns a 3D vector which forms the given angles with the +X axis.
static void orthonormalize(const vec3 &in1, const vec3 &in2, vec3 *out1, vec3 *out2) noexcept
Returns 2 3D vectors which are normalized and orthogonal to the two input vectors via output pointers...
vec3(float x, float y, float z) noexcept
Value constructor: initializes each component to its given value.
static vec3 cubic_hermite(const vec3 &v1, const vec3 &tangent1, const vec3 &v2, const vec3 &tangent2, float amount) noexcept
Calculates the cubic hermite interpolation between two vectors and their tangents.
static auto orthonormalize(const vec3 &in1, const vec3 &in2) noexcept
Returns 2 3D vectors which are normalized and orthogonal to the two input vectors as a std::pair<>.
static vec3 from_angles_deg(float azimuth_deg, float elevation_deg) noexcept
Returns a 3D vector which forms the given angles with the +X axis, in degrees.
vec3(const shz::vec2 &xy, float z) noexcept
Constructs a vec3 from a shz::vec2 and a scalar value for its z component.
vec3 cross(const vec3 &other) const noexcept
Returns a 3D vector which forms the given angles with the +X axis.
vec3(float v) noexcept
Single-value constructor: initializes all components to v.
vec3(const shz_vec3_t &other) noexcept
C constructor: constructs a C++ vec3 from a C shz_vec3_t.
vec3(float x, const shz::vec2 &yz) noexcept
Constructs a vec3 from a scalar as its x component and a shz::vec2 as its Y and Z components.
vec3 perp() const noexcept
Returns a 3D vector which is perpendicular to this vector.
float triple(const vec3 &b, const vec3 &c) const noexcept
Returns the 3D vector "triple product" between the given vector and vectors a and b.
vec3()=default
Default constructor: does nothing.
static vec3 from_angles(float azimuth_rads, float elevation_rads) noexcept
Returns a 3D vector which forms the given angles with the +X axis, in radians.
vec4(float x, float y, const shz::vec2 &zw) noexcept
Constructs a 4D vector with scalars providing X and Y coordinaets and a 2D vector providing Z and W.
vec4(float x, const shz::vec2 &yz, float w) noexcept
Constructs a 4D vector with scalars providing X and W coordinates and a 2D vector providing Y and Z.
vec4(float v) noexcept
Single-value constructor: initializes each element to the given value.
vec4(const shz::vec2 &xy, const shz::vec2 &zw) noexcept
Constructs a 4D vector from the components provided by the given pair of 2D vectors.
vec4(const shz_vec4_t &other) noexcept
C Constructor: initializes a C++ shz::vec4 from a C shz_vec4_t.
vec4(const shz::vec2 &xy, float z, float w) noexcept
Constructs a 4D vector with a 2D vector providing the X and Y coordinates and scalars providing Z and...
vec4(float x, const shz::vec3 &yzw) noexcept
Constructs a 4D vector with the X component given by a scalar and the Y, Z, and W components given by...
vec4(const shz::vec3 &xyz, float w) noexcept
Constructs a 4D vector with the X, Y, and Z components given by a 3D vector and W given by a scalar.
vec4()=default
Default constructor: does nothing.
vec4(float x, float y, float z, float w) noexcept
Value constructor: initializes each element to its corresponding parameter value.
Common C++ base structure inherited by all vector types.
CppType project(const CppType &onto) const noexcept
Returns the vector created from projecting the given vector onto another.
float magnitude_inv() const noexcept
Returns the inverse magnitude of the given vector.
T to() const noexcept
Conversion operator for going from a SH4ZAM vector type to another layout-compatible type.
float max() const noexcept
Returns the maximum value of every element within the vector.
CppType & operator-=(const CppType &other) noexcept
Overloaded subtraction assignment operator, subtracts a vector from the left-hand vector.
vecN(const vecN &other) noexcept=default
Default copy constructor.
CppType clamp(float min, float max) const noexcept
Returns a new vector whose values are the clamped components of the given vector.
CppType & operator*=(float other) noexcept
Overloaded multiplication assignment operator, multiplies and accumulates each vector component by th...
float min() const noexcept
Returns the minimum value of every element within the vector.
CppType round() const noexcept
Returns a new vector with the component-wise rounding of the given vector.
CppType project_safe(const CppType &onto) const noexcept
Returns the vector created from projecting the given vector onto another, safely protecting against d...
CppType maxv(const CppType &other) const noexcept
Returns a new vector with the component-wise maximum of two vectors.
static CppType smoothstep(const CppType &vec, T &&edge0, T &&edge1) noexcept
Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1.
static CppType from(const auto &raw) noexcept
Conversion operator for going from a layout-compatible vector type to a SH4ZAM vector type.
CppType ceil() const noexcept
Returns a new vector with the component-wise ceil of the given vector.
static constexpr size_t Rows
Number of rows.
float distance(const CppType &other) const noexcept
Returns the magnitude of the difference between two vectors as their distance.
CppType fract() const noexcept
Returns a new vector with the fractional part of each component.
CppType minv(const CppType &other) const noexcept
Returns a new vector with the component-wise minimum of two vectors.
CppType reflect(const CppType &normal) const noexcept
Returns the vector created from reflecting the given vector over the normal of a surface.
vecN(const CType &other) noexcept
Converting constructor from existing C instance.
CppType & operator+=(const CppType &other) noexcept
Overloaded operator for adding and accumulating a vector onto another.
friend CppType operator-(const CppType &vec) noexcept
Overloaded unary negation operator, returns the negated vector.
void normalize() noexcept
Normalizes the given vector.
CppType normalized_safe() const noexcept
Return the normalized vector, safely protecting against division-by-zero.
CppType & deref(const auto *raw) noexcept
Conversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM t...
static constexpr size_t Cols
Number of columns.
float distance_sqr(const CppType &other) const noexcept
Returns the value of the distance between two vectors squared (faster than actual distance)
CppType & operator/=(float other) noexcept
Overloaded division assignment operator, dividing and assigning each vector component by the given sc...
vec2 dot(const CppType &v1, const CppType &v2) const noexcept
Returns the dot product of the given vector against two others.
void normalize_safe() noexcept
Normalizes the given vector, safely protecting against division-by-zero.
CppType swizzle() const noexcept
Swizzle oeprator which takes a compile-time list of indices as non-type template arguments for the in...
CppType direction_safe() const noexcept
Returns the direction vector of a given vector, safely protecting against division-by-zero.
static CppType step(const CppType &vec, T &&edge) noexcept
Compares each component of the vector to the edge. 0 returned in that component if x[i] < edge....
CppType saturate() const noexcept
Returns a new vector with each component clamped to [0, 1].
CppType floor() const noexcept
Returns a new vector with the component-wise floor of the given vector.
CppType & operator/=(const CppType &other) noexcept
Overloaded division assignment operator, divides the left vector by the right, assigning the left to ...
auto angles() const noexcept
Returns the angle(s) created between the given vector axis and the +X axis, in radians.
vecN(const volatile CType &other) noexcept
Converting constructor from existing volatile C instance.
CppType normalized() const noexcept
Return the normalized vector.
CppType abs() const noexcept
Returns a new vector whose components are the absolute value of the given vector.
static CppType smoothstep_safe(const CppType &vec, T &&edge0, T &&edge1) noexcept
Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1.
CppType refract(const CppType &normal, float eta) const noexcept
Returns the vector create from refracting the given incidence vector over the normal of a surface,...
CppType direction() const noexcept
Returns the direction vector resulting from normalizing the given vector.
float magnitude_sqr() const noexcept
Returns the squared magnitude of the given vector.
vec3 dot(const CppType &v1, const CppType &v2, const CppType &v3) const noexcept
Returns the dot product of the given vector against three others.
float dot(const CppType &other) const noexcept
Returns the dot product of the given vector and another.
CppType neg() const noexcept
Returns a new vector whose components are the negative values of the given vector.
vecN() noexcept=default
Default constructor, does nothing.
float magnitude() const noexcept
Returns the magnitude of the given vector.
friend bool operator==(const CppType &lhs, const CppType &rhs) noexcept
Overloaded equality operator, for comparing vectors.
static CppType lerp(const CppType &start, const CppType &end, float t) noexcept
Returns the vector that is linearly interpolated between the two given vectors by the 0....
CppType sign() const noexcept
Returns a new vector with the sign of each component (-1, 0, or 1).
float angle_between(const CppType &other) const noexcept
Returns the angle between the given vector and another, in radians.
CppType move(const CppType &target, float maxdist) const noexcept
Moves the given vector towards the target by the given maxdist.
CppType inv() const noexcept
Returns a new vector whose components are the reciprocal values of the given vector.
CppType & operator*=(const CppType &other) noexcept
Overloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand...