SH4ZAM! 0.7.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
 
CppTypeoperator+= (const CppType &other) noexcept
 
CppTypeoperator-= (const CppType &other) noexcept
 
CppTypeoperator*= (const CppType &other) noexcept
 
CppTypeoperator/= (const 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 (const CppType &other) const noexcept
 
CppType maxv (const CppType &other) const noexcept
 
float dot (const CppType &other) const noexcept
 
vec2 dot (const CppType &v1, const CppType &v2) const noexcept
 
vec3 dot (const CppType &v1, const CppType &v2, const CppType &v3) const noexcept
 
float magnitude () const noexcept
 
float magnitude_sqr () const noexcept
 
float magnitude_inv () const noexcept
 
CppType direction () const noexcept
 
CppType direction_safe () const noexcept
 
void normalize () noexcept
 
void normalize_safe () noexcept
 
CppType normalized () const noexcept
 
CppType normalized_safe () const noexcept
 
float distance (const CppType &other) const noexcept
 
float distance_sqr (const CppType &other) const noexcept
 
CppType move (const CppType &target, float maxdist) const noexcept
 
CppType reflect (const CppType &normal) const noexcept
 
CppType refract (const CppType &normal, float eta) const noexcept
 
CppType project (const CppType &onto) const noexcept
 
CppType project_safe (const CppType &onto) const noexcept
 
float angle_between (const CppType &other) const noexcept
 
auto angles () const noexcept
 

Static Public Member Functions

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

Static Public Attributes

static constexpr size_t Rows
 
static constexpr size_t Cols
 

Friends

bool operator== (const CppType &lhs, const CppType &rhs) noexcept
 
CppType operator- (const 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 ( const CppType & start,
const 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 ( const 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 ( const 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 ( const 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>
CppType & shz::vecN< CRTP, C, R >::operator+= ( const CppType & other)
inlinenoexcept

Overloaded operator for adding and accumulating a vector onto another.

Definition at line 143 of file shz_vector.hpp.

143 {
144 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) + other;
145 return *static_cast<CppType*>(this);
146 }

◆ operator-=()

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

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

Definition at line 149 of file shz_vector.hpp.

149 {
150 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) - other;
151 return *static_cast<CppType*>(this);
152 }

◆ operator*=() [1/2]

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

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

Definition at line 155 of file shz_vector.hpp.

155 {
156 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) * other;
157 return *static_cast<CppType*>(this);
158 }

◆ operator/=() [1/2]

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

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

Definition at line 161 of file shz_vector.hpp.

161 {
162 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) / other;
163 return *static_cast<CppType*>(this);
164 }

◆ 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 167 of file shz_vector.hpp.

167 {
168 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) * other;
169 return *static_cast<CppType*>(this);
170 }

◆ 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 173 of file shz_vector.hpp.

173 {
174 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) / other;
175 return *static_cast<CppType*>(this);
176 }

◆ 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 180 of file shz_vector.hpp.

180 {
181 return shz_vec_swizzle(*static_cast<const CppType*>(this), Indices...);
182 }
#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 185 of file shz_vector.hpp.

185 {
186 return shz_vec_abs(*static_cast<const CppType*>(this));
187 }
#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 190 of file shz_vector.hpp.

190 {
191 return shz_vec_neg(*static_cast<const CppType*>(this));
192 }
#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 195 of file shz_vector.hpp.

195 {
196 return shz_vec_inv(*static_cast<const CppType*>(this));
197 }
#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 200 of file shz_vector.hpp.

200 {
201 return shz_vec_max(*static_cast<const CppType*>(this));
202 }
#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 205 of file shz_vector.hpp.

205 {
206 return shz_vec_min(*static_cast<const CppType*>(this));
207 }
#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 210 of file shz_vector.hpp.

210 {
211 return shz_vec_clamp(*static_cast<const CppType*>(this), min, max);
212 }
#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 215 of file shz_vector.hpp.

215 {
216 return shz_vec_floor(*static_cast<const CppType*>(this));
217 }
#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 220 of file shz_vector.hpp.

220 {
221 return shz_vec_ceil(*static_cast<const CppType*>(this));
222 }
#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 225 of file shz_vector.hpp.

225 {
226 return shz_vec_round(*static_cast<const CppType*>(this));
227 }
#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 230 of file shz_vector.hpp.

230 {
231 return shz_vec_fract(*static_cast<const CppType*>(this));
232 }
#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 235 of file shz_vector.hpp.

235 {
236 return shz_vec_sign(*static_cast<const CppType*>(this));
237 }
#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 240 of file shz_vector.hpp.

240 {
241 return shz_vec_saturate(*static_cast<const CppType*>(this));
242 }
#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 ( const CppType & other) const
inlinenoexcept

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

Definition at line 245 of file shz_vector.hpp.

245 {
246 return shz_vec_minv(*static_cast<const CppType*>(this), other);
247 }
#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 ( const CppType & other) const
inlinenoexcept

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

Definition at line 250 of file shz_vector.hpp.

250 {
251 return shz_vec_maxv(*static_cast<const CppType*>(this), other);
252 }
#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 ( const CppType & other) const
inlinenoexcept

Returns the dot product of the given vector and another.

Definition at line 255 of file shz_vector.hpp.

255 {
256 return shz_vec_dot(*static_cast<const CppType*>(this), other);
257 }
#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 ( const CppType & v1,
const CppType & v2 ) const
noexcept

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

Definition at line 638 of file shz_vector.hpp.

638 {
639 return shz_vec_dot2(*static_cast<const CRTP*>(this), v1, v2);
640}
#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 ( const CppType & v1,
const CppType & v2,
const CppType & v3 ) const
noexcept

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

Definition at line 643 of file shz_vector.hpp.

643 {
644 return shz_vec_dot3(*static_cast<const CRTP*>(this), v1, v2, v3);
645}
#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 266 of file shz_vector.hpp.

266 {
267 return shz_vec_magnitude(*static_cast<const CppType*>(this));
268 }
#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 271 of file shz_vector.hpp.

271 {
272 return shz_vec_magnitude_sqr(*static_cast<const CppType*>(this));
273 }
#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 276 of file shz_vector.hpp.

276 {
277 return shz_vec_magnitude_inv(*static_cast<const CppType*>(this));
278 }
#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 281 of file shz_vector.hpp.

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

◆ 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 286 of file shz_vector.hpp.

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

◆ normalize()

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

Normalizes the given vector.

Definition at line 291 of file shz_vector.hpp.

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

◆ 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 296 of file shz_vector.hpp.

296 {
297 *static_cast<CppType*>(this) = shz_vec_normalize_safe(*static_cast<const CppType*>(this));
298 }

◆ normalized()

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

Return the normalized vector.

Definition at line 301 of file shz_vector.hpp.

301 {
302 return shz_vec_normalize(*static_cast<const CppType*>(this));
303 }

◆ normalized_safe()

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

Return the normalized vector, safely protecting against division-by-zero.

Definition at line 306 of file shz_vector.hpp.

306 {
307 return shz_vec_normalize_safe(*static_cast<const CppType*>(this));
308 }

◆ 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 311 of file shz_vector.hpp.

311 {
312 return shz_vec_distance(*static_cast<const CppType*>(this), other);
313 }
#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 316 of file shz_vector.hpp.

316 {
317 return shz_vec_distance_sqr(*static_cast<const CppType*>(this), other);
318 }
#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 ( const CppType & target,
float maxdist ) const
inlinenoexcept

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

Definition at line 321 of file shz_vector.hpp.

321 {
322 return shz_vec_move(*static_cast<const CppType*>(this), target, maxdist);
323 }
#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 ( const CppType & normal) const
inlinenoexcept

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

Definition at line 326 of file shz_vector.hpp.

326 {
327 return shz_vec_reflect(*static_cast<const CppType*>(this), normal);
328 }
#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 ( const 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 331 of file shz_vector.hpp.

331 {
332 return shz_vec_refract(*static_cast<const CppType*>(this), normal, eta);
333 }
#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 ( const CppType & onto) const
inlinenoexcept

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

Definition at line 336 of file shz_vector.hpp.

336 {
337 return shz_vec_project(*static_cast<const CppType*>(this), onto);
338 }
#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 ( const CppType & onto) const
inlinenoexcept

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

Definition at line 341 of file shz_vector.hpp.

341 {
342 return shz_vec_project_safe(*static_cast<const CppType*>(this), onto);
343 }
#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 ( const CppType & other) const
inlinenoexcept

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

Definition at line 346 of file shz_vector.hpp.

346 {
347 return shz_vec_angle_between(*static_cast<const CppType*>(this), other);
348 }
#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 351 of file shz_vector.hpp.

351 {
352 return shz_vec_angles(*static_cast<const CppType*>(this));
353 }
#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== ( const CppType & lhs,
const CppType & rhs )
friend

Overloaded equality operator, for comparing vectors.

Definition at line 133 of file shz_vector.hpp.

133 {
134 return shz_vec_equal(lhs, rhs);
135 }
#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- ( const CppType & vec)
friend

Overloaded unary negation operator, returns the negated vector.

Definition at line 138 of file shz_vector.hpp.

138 {
139 return vec.neg();
140 }
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: