SH4ZAM! 0.1.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz::vecN< CRTP, C, R > Struct Template Reference

#include <shz_vector.hpp>

Inheritance diagram for shz::vecN< CRTP, C, R >:
Collaboration diagram for shz::vecN< CRTP, C, R >:

Public Types

using CppType
 
using CType
 

Public Member Functions

 vecN () noexcept=default
 
 vecN (const vecN &other) noexcept=default
 
 vecN (const CType &other) noexcept
 
 vecN (const volatile CType &other) noexcept
 
template<typename T>
to () const noexcept
 
CppTypederef (const auto *raw) noexcept
 
volatile CppTypeoperator= (volatile CType other) volatile noexcept
 
CppTypeoperator+= (CppType other) noexcept
 
CppTypeoperator-= (CppType other) noexcept
 
CppTypeoperator*= (CppType other) noexcept
 
CppTypeoperator/= (CppType other) noexcept
 
CppTypeoperator*= (float other) noexcept
 
CppTypeoperator/= (float other) noexcept
 
template<unsigned... Indices>
CppType swizzle () const noexcept
 
CppType abs () const noexcept
 
CppType neg () const noexcept
 
CppType inv () const noexcept
 
float max () const noexcept
 
float min () const noexcept
 
CppType clamp (float min, float max) const noexcept
 
CppType floor () const noexcept
 
CppType ceil () const noexcept
 
CppType round () const noexcept
 
CppType fract () const noexcept
 
CppType sign () const noexcept
 
CppType saturate () const noexcept
 
CppType minv (CppType other) const noexcept
 
CppType maxv (CppType other) const noexcept
 
float dot (CppType other) const noexcept
 
vec2 dot (CppType v1, CppType v2) const noexcept
 
vec3 dot (CppType v1, CppType v2, CppType v3) const noexcept
 
float magnitude () const noexcept
 
float magnitude_sqr () const noexcept
 
float magnitude_inv () const noexcept
 
CppType direction () const noexcept
 
void normalize () noexcept
 
CppType direction_safe () const noexcept
 
void normalize_safe () noexcept
 
float distance (const CppType &other) const noexcept
 
float distance_sqr (const CppType &other) const noexcept
 
CppType move (CppType target, float maxdist) const noexcept
 
CppType reflect (CppType normal) const noexcept
 
CppType refract (CppType normal, float eta) const noexcept
 
CppType project (CppType onto) const noexcept
 
CppType project_safe (CppType onto) const noexcept
 
float angle_between (CppType other) const noexcept
 
auto angles () const noexcept
 

Static Public Member Functions

static CppType from (const auto &raw) noexcept
 
static CppType lerp (CppType start, CppType end, float t) noexcept
 
template<typename T>
static CppType step (CppType vec, T edge) noexcept
 
template<typename T>
static CppType smoothstep (CppType vec, T edge0, T edge1) noexcept
 
template<typename T>
static CppType smoothstep_safe (CppType vec, T edge0, T edge1) noexcept
 

Static Public Attributes

static constexpr size_t Rows
 
static constexpr size_t Cols
 

Friends

bool operator== (CppType lhs, CppType rhs) noexcept
 
CppType operator- (CppType vec) noexcept
 

Detailed Description

template<typename CRTP, typename C, size_t R>
struct shz::vecN< CRTP, C, R >

Common C++ base structure inherited by all vector types.

This struct template serves as the base class for all concrete vector types, providing:

  • Common API routines
  • Adaptor between C and C++ types
  • Convenience overloaded operators and STL iterators.
See also
shz::vec2, shz::vec3, shz::vec4

Definition at line 43 of file shz_vector.hpp.

Member Typedef Documentation

◆ CppType

template<typename CRTP, typename C, size_t R>
using shz::vecN< CRTP, C, R >::CppType

Cpp derived type.

Definition at line 44 of file shz_vector.hpp.

◆ CType

template<typename CRTP, typename C, size_t R>
using shz::vecN< CRTP, C, R >::CType

C base type.

Definition at line 45 of file shz_vector.hpp.

Constructor & Destructor Documentation

◆ vecN() [1/4]

template<typename CRTP, typename C, size_t R>
shz::vecN< CRTP, C, R >::vecN ( )
defaultnoexcept

Default constructor, does nothing.

◆ vecN() [2/4]

template<typename CRTP, typename C, size_t R>
shz::vecN< CRTP, C, R >::vecN ( const vecN< CRTP, C, R > & other)
defaultnoexcept

Default copy constructor.

◆ vecN() [3/4]

template<typename CRTP, typename C, size_t R>
shz::vecN< CRTP, C, R >::vecN ( const CType & other)
inlinenoexcept

Converting constructor from existing C instance.

Definition at line 57 of file shz_vector.hpp.

57 :
58 CType(other) {}
Common C++ base structure inherited by all vector types.
C CType
C base type.

◆ vecN() [4/4]

template<typename CRTP, typename C, size_t R>
shz::vecN< CRTP, C, R >::vecN ( const volatile CType & other)
inlinenoexcept

Converting constructor from existing volatile C instance.

Definition at line 61 of file shz_vector.hpp.

61 :
62 CType(const_cast<const CType&>(other)) {}

Member Function Documentation

◆ from()

template<typename CRTP, typename C, size_t R>
static CppType shz::vecN< CRTP, C, R >::from ( const auto & raw)
inlinestaticnoexcept

Conversion operator for going from a layout-compatible vector type to a SH4ZAM vector type.

Definition at line 65 of file shz_vector.hpp.

65 {
66 return *reinterpret_cast<const CppType*>(&raw);
67 }
CRTP CppType
Cpp derived type.

◆ to()

template<typename CRTP, typename C, size_t R>
template<typename T>
T shz::vecN< CRTP, C, R >::to ( ) const
inlinenoexcept

Conversion operator for going from a SH4ZAM vector type to another layout-compatible type.

Definition at line 71 of file shz_vector.hpp.

71 {
72 return *reinterpret_cast<const T*>(this);
73 }

◆ deref()

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::deref ( const auto * raw)
inlinenoexcept

Conversion operator for accessing an existing pointer type as though it were a refrence to a SH4ZAM type.

Definition at line 76 of file shz_vector.hpp.

76 {
77 return *const_cast<CppType*>(reinterpret_cast<const CppType*>(raw));
78 }

◆ lerp()

template<typename CRTP, typename C, size_t R>
static CppType shz::vecN< CRTP, C, R >::lerp ( CppType start,
CppType end,
float t )
inlinestaticnoexcept

Returns the vector that is linearly interpolated between the two given vectors by the 0.0f-1.0f factor, t.

Definition at line 81 of file shz_vector.hpp.

81 {
82 return shz_vec_lerp(start, end, t);
83 }
#define shz_vec_lerp(vec1, vec2, t)
C type-generic linear interpolation between two vectors.
Definition shz_vector.h:874

◆ step()

template<typename CRTP, typename C, size_t R>
template<typename T>
static CppType shz::vecN< CRTP, C, R >::step ( CppType vec,
T edge )
inlinestaticnoexcept

Compares each component of the vector to the edge. 0 returned in that component if x[i] < edge. Otherwise the component is 1.

Definition at line 87 of file shz_vector.hpp.

87 {
88 return shz_vec_step(vec, edge);
89 }
#define shz_vec_step(vec, edge)
C type-generic step.
Definition shz_vector.h:997

◆ smoothstep()

template<typename CRTP, typename C, size_t R>
template<typename T>
static CppType shz::vecN< CRTP, C, R >::smoothstep ( CppType vec,
T edge0,
T edge1 )
inlinestaticnoexcept

Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1.

Definition at line 93 of file shz_vector.hpp.

93 {
95 }
#define shz_vec_smoothstep(vec, edge0, edge1)
C type-generic smoothstep.

◆ smoothstep_safe()

template<typename CRTP, typename C, size_t R>
template<typename T>
static CppType shz::vecN< CRTP, C, R >::smoothstep_safe ( CppType vec,
T edge0,
T edge1 )
inlinestaticnoexcept

Returns a vector where each component is smoothly interpolated from 0 to 1 between edge0 and edge1.

Definition at line 99 of file shz_vector.hpp.

99 {
101 }
#define shz_vec_smoothstep_safe(vec, edge0, edge1)
C type-generic smoothstep_safe.

◆ operator=()

template<typename CRTP, typename C, size_t R>
volatile CppType & shz::vecN< CRTP, C, R >::operator= ( volatile CType other) volatile
inlinenoexcept

Overloaded operator for assigning to volatile reference to base C type.

Definition at line 141 of file shz_vector.hpp.

141 {
142 *static_cast<CppType*>(const_cast<vecN*>(this)) = CppType(const_cast<CType&>(other));
143 return *static_cast<volatile CppType*>(this);
144 }
vecN() noexcept=default
Default constructor, does nothing.

◆ operator+=()

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::operator+= ( CppType other)
inlinenoexcept

Overloaded operator for adding and accumulating a vector onto another.

Definition at line 147 of file shz_vector.hpp.

147 {
148 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) + other;
149 return *static_cast<CppType*>(this);
150 }

◆ operator-=()

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::operator-= ( CppType other)
inlinenoexcept

Overloaded subtraction assignment operator, subtracts a vector from the left-hand vector.

Definition at line 153 of file shz_vector.hpp.

153 {
154 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) - other;
155 return *static_cast<CppType*>(this);
156 }

◆ operator*=() [1/2]

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::operator*= ( CppType other)
inlinenoexcept

Overloaded multiplication assignment operator, multiplies and accumulates a vector onto the left-hand vector.

Definition at line 159 of file shz_vector.hpp.

159 {
160 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) * other;
161 return *static_cast<CppType*>(this);
162 }

◆ operator/=() [1/2]

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::operator/= ( CppType other)
inlinenoexcept

Overloaded division assignment operator, divides the left vector by the right, assigning the left to the result.

Definition at line 165 of file shz_vector.hpp.

165 {
166 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) / other;
167 return *static_cast<CppType*>(this);
168 }

◆ operator*=() [2/2]

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::operator*= ( float other)
inlinenoexcept

Overloaded multiplication assignment operator, multiplies and accumulates each vector component by the given scalar.

Definition at line 171 of file shz_vector.hpp.

171 {
172 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) * other;
173 return *static_cast<CppType*>(this);
174 }

◆ operator/=() [2/2]

template<typename CRTP, typename C, size_t R>
CppType & shz::vecN< CRTP, C, R >::operator/= ( float other)
inlinenoexcept

Overloaded division assignment operator, dividing and assigning each vector component by the given scalar value.

Definition at line 177 of file shz_vector.hpp.

177 {
178 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) / other;
179 return *static_cast<CppType*>(this);
180 }

◆ swizzle()

template<typename CRTP, typename C, size_t R>
template<unsigned... Indices>
CppType shz::vecN< CRTP, C, R >::swizzle ( ) const
inlinenoexcept

Swizzle oeprator which takes a compile-time list of indices as non-type template arguments for the index each element should use as its new value.

Definition at line 184 of file shz_vector.hpp.

184 {
185 return shz_vec_swizzle(*static_cast<const CppType*>(this), Indices...);
186 }
#define shz_vec_swizzle(vec,...)
C type-generic vector swizzling.
Definition shz_vector.h:927

◆ abs()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::abs ( ) const
inlinenoexcept

Returns a new vector whose components are the absolute value of the given vector.

Definition at line 189 of file shz_vector.hpp.

189 {
190 return shz_vec_abs(*static_cast<const CppType*>(this));
191 }
#define shz_vec_abs(vec)
C type-generic vector absolute value.
Definition shz_vector.h:713

◆ neg()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::neg ( ) const
inlinenoexcept

Returns a new vector whose components are the negative values of the given vector.

Definition at line 194 of file shz_vector.hpp.

194 {
195 return shz_vec_neg(*static_cast<const CppType*>(this));
196 }
#define shz_vec_neg(vec)
C type-generic vector negation.
Definition shz_vector.h:720

◆ inv()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::inv ( ) const
inlinenoexcept

Returns a new vector whose components are the reciprocal values of the given vector.

Definition at line 199 of file shz_vector.hpp.

199 {
200 return shz_vec_inv(*static_cast<const CppType*>(this));
201 }
#define shz_vec_inv(vec)
C type-generic vector inversion.
Definition shz_vector.h:727

◆ max()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::max ( ) const
inlinenoexcept

Returns the maximum value of every element within the vector.

Definition at line 204 of file shz_vector.hpp.

204 {
205 return shz_vec_max(*static_cast<const CppType*>(this));
206 }
#define shz_vec_max(vec)
C type-generic vector maximum value.
Definition shz_vector.h:734

◆ min()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::min ( ) const
inlinenoexcept

Returns the minimum value of every element within the vector.

Definition at line 209 of file shz_vector.hpp.

209 {
210 return shz_vec_min(*static_cast<const CppType*>(this));
211 }
#define shz_vec_min(vec)
C type-generic vector minimum value.
Definition shz_vector.h:741

◆ clamp()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::clamp ( float min,
float max ) const
inlinenoexcept

Returns a new vector whose values are the clamped components of the given vector.

Definition at line 214 of file shz_vector.hpp.

214 {
215 return shz_vec_clamp(*static_cast<const CppType*>(this), min, max);
216 }
#define shz_vec_clamp(vec, min, max)
C type-generic vector minimum value.
Definition shz_vector.h:748
float max() const noexcept
Returns the maximum value of every element within the vector.
float min() const noexcept
Returns the minimum value of every element within the vector.

◆ floor()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::floor ( ) const
inlinenoexcept

Returns a new vector with the component-wise floor of the given vector.

Definition at line 219 of file shz_vector.hpp.

219 {
220 return shz_vec_floor(*static_cast<const CppType*>(this));
221 }
#define shz_vec_floor(vec)
C type-generic component-wise floor.
Definition shz_vector.h:934

◆ ceil()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::ceil ( ) const
inlinenoexcept

Returns a new vector with the component-wise ceil of the given vector.

Definition at line 224 of file shz_vector.hpp.

224 {
225 return shz_vec_ceil(*static_cast<const CppType*>(this));
226 }
#define shz_vec_ceil(vec)
C type-generic component-wise ceil.
Definition shz_vector.h:941

◆ round()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::round ( ) const
inlinenoexcept

Returns a new vector with the component-wise rounding of the given vector.

Definition at line 229 of file shz_vector.hpp.

229 {
230 return shz_vec_round(*static_cast<const CppType*>(this));
231 }
#define shz_vec_round(vec)
C type-generic component-wise round.
Definition shz_vector.h:948

◆ fract()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::fract ( ) const
inlinenoexcept

Returns a new vector with the fractional part of each component.

Definition at line 234 of file shz_vector.hpp.

234 {
235 return shz_vec_fract(*static_cast<const CppType*>(this));
236 }
#define shz_vec_fract(vec)
C type-generic component-wise fract.
Definition shz_vector.h:955

◆ sign()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::sign ( ) const
inlinenoexcept

Returns a new vector with the sign of each component (-1, 0, or 1).

Definition at line 239 of file shz_vector.hpp.

239 {
240 return shz_vec_sign(*static_cast<const CppType*>(this));
241 }
#define shz_vec_sign(vec)
C type-generic component-wise sign.
Definition shz_vector.h:962

◆ saturate()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::saturate ( ) const
inlinenoexcept

Returns a new vector with each component clamped to [0, 1].

Definition at line 244 of file shz_vector.hpp.

244 {
245 return shz_vec_saturate(*static_cast<const CppType*>(this));
246 }
#define shz_vec_saturate(vec)
C type-generic component-wise saturate.
Definition shz_vector.h:969

◆ minv()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::minv ( CppType other) const
inlinenoexcept

Returns a new vector with the component-wise minimum of two vectors.

Definition at line 249 of file shz_vector.hpp.

249 {
250 return shz_vec_minv(*static_cast<const CppType*>(this), other);
251 }
#define shz_vec_minv(a, b)
C type-generic pairwise minimum.
Definition shz_vector.h:976

◆ maxv()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::maxv ( CppType other) const
inlinenoexcept

Returns a new vector with the component-wise maximum of two vectors.

Definition at line 254 of file shz_vector.hpp.

254 {
255 return shz_vec_maxv(*static_cast<const CppType*>(this), other);
256 }
#define shz_vec_maxv(a, b)
C type-generic pairwise maximum.
Definition shz_vector.h:983

◆ dot() [1/3]

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::dot ( CppType other) const
inlinenoexcept

Returns the dot product of the given vector and another.

Definition at line 259 of file shz_vector.hpp.

259 {
260 return shz_vec_dot(*static_cast<const CppType*>(this), other);
261 }
#define shz_vec_dot(vec1, vec2)
C type-generic vector dot product.
Definition shz_vector.h:797

◆ dot() [2/3]

template<typename CRTP, typename C, size_t R>
vec2 shz::vecN< CRTP, C, R >::dot ( CppType v1,
CppType v2 ) const
noexcept

Returns the dot product of the given vector against two others.

Definition at line 626 of file shz_vector.hpp.

626 {
627 return shz_vec_dot2(*static_cast<const CRTP*>(this), v1, v2);
628}
#define shz_vec_dot2(l, r1, r2)
C type-generic vector chained double dot product.
Definition shz_vector.h:804

◆ dot() [3/3]

template<typename CRTP, typename C, size_t R>
vec3 shz::vecN< CRTP, C, R >::dot ( CppType v1,
CppType v2,
CppType v3 ) const
noexcept

Returns the dot product of the given vector against three others.

Definition at line 631 of file shz_vector.hpp.

631 {
632 return shz_vec_dot3(*static_cast<const CRTP*>(this), v1, v2, v3);
633}
#define shz_vec_dot3(l, r1, r2, r3)
C type-generic vector chained triple dot product.
Definition shz_vector.h:811

◆ magnitude()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::magnitude ( ) const
inlinenoexcept

Returns the magnitude of the given vector.

Definition at line 270 of file shz_vector.hpp.

270 {
271 return shz_vec_magnitude(*static_cast<const CppType*>(this));
272 }
#define shz_vec_magnitude(vec)
C type-generic vector magnitude.
Definition shz_vector.h:825

◆ magnitude_sqr()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::magnitude_sqr ( ) const
inlinenoexcept

Returns the squared magnitude of the given vector.

Definition at line 275 of file shz_vector.hpp.

275 {
276 return shz_vec_magnitude_sqr(*static_cast<const CppType*>(this));
277 }
#define shz_vec_magnitude_sqr(vec)
C type-generic vector squared magnitude.
Definition shz_vector.h:818

◆ magnitude_inv()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::magnitude_inv ( ) const
inlinenoexcept

Returns the inverse magnitude of the given vector.

Definition at line 280 of file shz_vector.hpp.

280 {
281 return shz_vec_magnitude_inv(*static_cast<const CppType*>(this));
282 }
#define shz_vec_magnitude_inv(vec)
C type-generic vector inverse magnitude.
Definition shz_vector.h:832

◆ direction()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::direction ( ) const
inlinenoexcept

Returns the direction vector resulting from normalizing the given vector.

Definition at line 285 of file shz_vector.hpp.

285 {
286 return shz_vec_normalize(*static_cast<const CppType*>(this));
287 }
#define shz_vec_normalize(vec)
C type-generic vector normalization.
Definition shz_vector.h:839

◆ normalize()

template<typename CRTP, typename C, size_t R>
void shz::vecN< CRTP, C, R >::normalize ( )
inlinenoexcept

Normalizes the given vector.

Definition at line 290 of file shz_vector.hpp.

290 {
291 *static_cast<CppType*>(this) = shz_vec_normalize(*static_cast<const CppType*>(this));
292 }

◆ direction_safe()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::direction_safe ( ) const
inlinenoexcept

Returns the direction vector of a given vector, safely protecting against division-by-zero.

Definition at line 295 of file shz_vector.hpp.

295 {
296 return shz_vec_normalize_safe(*static_cast<const CppType*>(this));
297 }
#define shz_vec_normalize_safe(vec)
C type-generic safe vector normalization.
Definition shz_vector.h:846

◆ normalize_safe()

template<typename CRTP, typename C, size_t R>
void shz::vecN< CRTP, C, R >::normalize_safe ( )
inlinenoexcept

Normalizes the given vector, safely protecting against division-by-zero.

Definition at line 300 of file shz_vector.hpp.

300 {
301 *static_cast<CppType*>(this) = shz_vec_normalize_safe(*static_cast<const CppType*>(this));
302 }

◆ distance()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::distance ( const CppType & other) const
inlinenoexcept

Returns the magnitude of the difference between two vectors as their distance.

Definition at line 305 of file shz_vector.hpp.

305 {
306 return shz_vec_distance(*static_cast<const CppType*>(this), other);
307 }
#define shz_vec_distance(vec1, vec2)
C type-generic vector distance.
Definition shz_vector.h:853

◆ distance_sqr()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::distance_sqr ( const CppType & other) const
inlinenoexcept

Returns the value of the distance between two vectors squared (faster than actual distance)

Definition at line 310 of file shz_vector.hpp.

310 {
311 return shz_vec_distance_sqr(*static_cast<const CppType*>(this), other);
312 }
#define shz_vec_distance_sqr(vec1, vec2)
C type-generic vector squared distance.
Definition shz_vector.h:867

◆ move()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::move ( CppType target,
float maxdist ) const
inlinenoexcept

Moves the given vector towards the target by the given maxdist.

Definition at line 315 of file shz_vector.hpp.

315 {
316 return shz_vec_move(*static_cast<const CppType*>(this), target, maxdist);
317 }
#define shz_vec_move(vec, target, maxdist)
C type-generic vector move.
Definition shz_vector.h:860

◆ reflect()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::reflect ( CppType normal) const
inlinenoexcept

Returns the vector created from reflecting the given vector over the normal of a surface.

Definition at line 320 of file shz_vector.hpp.

320 {
321 return shz_vec_reflect(*static_cast<const CppType*>(this), normal);
322 }
#define shz_vec_reflect(incidence, normal)
C type-generic vector reflection.
Definition shz_vector.h:881

◆ refract()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::refract ( CppType normal,
float eta ) const
inlinenoexcept

Returns the vector create from refracting the given incidence vector over the normal of a surface, using the given refraction ratio index.

Definition at line 325 of file shz_vector.hpp.

325 {
326 return shz_vec_refract(*static_cast<const CppType*>(this), normal, eta);
327 }
#define shz_vec_refract(incidence, normal, eta)
C type-generic vector refraction.
Definition shz_vector.h:888

◆ project()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::project ( CppType onto) const
inlinenoexcept

Returns the vector created from projecting the given vector onto another.

Definition at line 330 of file shz_vector.hpp.

330 {
331 return shz_vec_project(*static_cast<const CppType*>(this), onto);
332 }
#define shz_vec_project(vec1, vec2)
C type-generic vector projection.
Definition shz_vector.h:901

◆ project_safe()

template<typename CRTP, typename C, size_t R>
CppType shz::vecN< CRTP, C, R >::project_safe ( CppType onto) const
inlinenoexcept

Returns the vector created from projecting the given vector onto another, safely protecting against division-by-zero.

Definition at line 335 of file shz_vector.hpp.

335 {
336 return shz_vec_project_safe(*static_cast<const CppType*>(this), onto);
337 }
#define shz_vec_project_safe(vec1, vec2)
C type-generic safe vector projection.
Definition shz_vector.h:908

◆ angle_between()

template<typename CRTP, typename C, size_t R>
float shz::vecN< CRTP, C, R >::angle_between ( CppType other) const
inlinenoexcept

Returns the angle between the given vector and another, in radians.

Definition at line 340 of file shz_vector.hpp.

340 {
341 return shz_vec_angle_between(*static_cast<const CppType*>(this), other);
342 }
#define shz_vec_angle_between(vec1, vec2)
C type-generic angle between two vectors.
Definition shz_vector.h:921

◆ angles()

template<typename CRTP, typename C, size_t R>
auto shz::vecN< CRTP, C, R >::angles ( ) const
inlinenoexcept

Returns the angle(s) created between the given vector axis and the +X axis, in radians.

Definition at line 345 of file shz_vector.hpp.

345 {
346 return shz_vec_angles(*static_cast<const CppType*>(this));
347 }
#define shz_vec_angles(vec)
C type-generic angle-from-vector extraction.
Definition shz_vector.h:915

Friends And Related Symbol Documentation

◆ operator==

template<typename CRTP, typename C, size_t R>
bool operator== ( CppType lhs,
CppType rhs )
friend

Overloaded equality operator, for comparing vectors.

Definition at line 131 of file shz_vector.hpp.

131 {
132 return shz_vec_equal(lhs, rhs);
133 }
#define shz_vec_equal(vec1, vec2)
C type-generic vector equals.
Definition shz_vector.h:755

◆ operator-

template<typename CRTP, typename C, size_t R>
CppType operator- ( CppType vec)
friend

Overloaded unary negation operator, returns the negated vector.

Definition at line 136 of file shz_vector.hpp.

136 {
137 return vec.neg();
138 }
CppType neg() const noexcept
Returns a new vector whose components are the negative values of the given vector.

Field Documentation

◆ Rows

template<typename CRTP, typename C, size_t R>
size_t shz::vecN< CRTP, C, R >::Rows
staticconstexpr

Number of rows.

Definition at line 47 of file shz_vector.hpp.

◆ Cols

template<typename CRTP, typename C, size_t R>
size_t shz::vecN< CRTP, C, R >::Cols
staticconstexpr

Number of columns.

Definition at line 48 of file shz_vector.hpp.


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