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 ()=default
 
 vecN (CType other) noexcept
 
template<typename T>
to () const noexcept
 
CppTypederef (const auto *raw) 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

auto 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/2]

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

Default constructor, does nothing.

◆ vecN() [2/2]

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

Converting constructor from existing C instance.

Definition at line 54 of file shz_vector.hpp.

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

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

58 {
59 return *reinterpret_cast<const CppType*>(&raw);
60 }
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 64 of file shz_vector.hpp.

64 {
65 return *reinterpret_cast<const T*>(this);
66 }

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

69 {
70 return *const_cast<CppType*>(reinterpret_cast<const CppType*>(raw));
71 }

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

74 {
75 return shz_vec_lerp(start, end, t);
76 }
#define shz_vec_lerp(vec1, vec2, t)
C type-generic linear interpolation between two vectors.
Definition shz_vector.h:855

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

80 {
81 return shz_vec_step(vec, edge);
82 }
#define shz_vec_step(vec, edge)
C type-generic step.
Definition shz_vector.h:978

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

86 {
88 }
#define shz_vec_smoothstep(vec, edge0, edge1)
C type-generic smoothstep.
Definition shz_vector.h:992

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

92 {
94 }
#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+= ( CppType other)
inlinenoexcept

Overloaded operator for adding and accumulating a vector onto another.

Definition at line 134 of file shz_vector.hpp.

134 {
135 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) + other;
136 return *static_cast<CppType*>(this);
137 }

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

140 {
141 *static_cast<CppType*>(this) = *static_cast<CppType*>(this) - other;
142 return *static_cast<CppType*>(this);
143 }

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

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

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

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

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

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

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

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

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

171 {
172 return shz_vec_swizzle(*static_cast<const CppType*>(this), Indices...);
173 }
#define shz_vec_swizzle(vec,...)
C type-generic vector swizzling.
Definition shz_vector.h:908

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

176 {
177 return shz_vec_abs(*static_cast<const CppType*>(this));
178 }
#define shz_vec_abs(vec)
C type-generic vector absolute value.
Definition shz_vector.h:694

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

181 {
182 return shz_vec_neg(*static_cast<const CppType*>(this));
183 }
#define shz_vec_neg(vec)
C type-generic vector negation.
Definition shz_vector.h:701

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

186 {
187 return shz_vec_inv(*static_cast<const CppType*>(this));
188 }
#define shz_vec_inv(vec)
C type-generic vector inversion.
Definition shz_vector.h:708

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

191 {
192 return shz_vec_max(*static_cast<const CppType*>(this));
193 }
#define shz_vec_max(vec)
C type-generic vector maximum value.
Definition shz_vector.h:715

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

196 {
197 return shz_vec_min(*static_cast<const CppType*>(this));
198 }
#define shz_vec_min(vec)
C type-generic vector minimum value.
Definition shz_vector.h:722

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

201 {
202 return shz_vec_clamp(*static_cast<const CppType*>(this), min, max);
203 }
#define shz_vec_clamp(vec, min, max)
C type-generic vector minimum value.
Definition shz_vector.h:729
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 206 of file shz_vector.hpp.

206 {
207 return shz_vec_floor(*static_cast<const CppType*>(this));
208 }
#define shz_vec_floor(vec)
C type-generic component-wise floor.
Definition shz_vector.h:915

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

211 {
212 return shz_vec_ceil(*static_cast<const CppType*>(this));
213 }
#define shz_vec_ceil(vec)
C type-generic component-wise ceil.
Definition shz_vector.h:922

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

216 {
217 return shz_vec_round(*static_cast<const CppType*>(this));
218 }
#define shz_vec_round(vec)
C type-generic component-wise round.
Definition shz_vector.h:929

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

221 {
222 return shz_vec_fract(*static_cast<const CppType*>(this));
223 }
#define shz_vec_fract(vec)
C type-generic component-wise fract.
Definition shz_vector.h:936

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

226 {
227 return shz_vec_sign(*static_cast<const CppType*>(this));
228 }
#define shz_vec_sign(vec)
C type-generic component-wise sign.
Definition shz_vector.h:943

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

231 {
232 return shz_vec_saturate(*static_cast<const CppType*>(this));
233 }
#define shz_vec_saturate(vec)
C type-generic component-wise saturate.
Definition shz_vector.h:950

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

236 {
237 return shz_vec_minv(*static_cast<const CppType*>(this), other);
238 }
#define shz_vec_minv(a, b)
C type-generic pairwise minimum.
Definition shz_vector.h:957

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

241 {
242 return shz_vec_maxv(*static_cast<const CppType*>(this), other);
243 }
#define shz_vec_maxv(a, b)
C type-generic pairwise maximum.
Definition shz_vector.h:964

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

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

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

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

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

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

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

257 {
258 return shz_vec_magnitude(*static_cast<const CppType*>(this));
259 }
#define shz_vec_magnitude(vec)
C type-generic vector magnitude.
Definition shz_vector.h:806

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

262 {
263 return shz_vec_magnitude_sqr(*static_cast<const CppType*>(this));
264 }
#define shz_vec_magnitude_sqr(vec)
C type-generic vector squared magnitude.
Definition shz_vector.h:799

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

267 {
268 return shz_vec_magnitude_inv(*static_cast<const CppType*>(this));
269 }
#define shz_vec_magnitude_inv(vec)
C type-generic vector inverse magnitude.
Definition shz_vector.h:813

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

272 {
273 return shz_vec_normalize(*static_cast<const CppType*>(this));
274 }
#define shz_vec_normalize(vec)
C type-generic vector normalization.
Definition shz_vector.h:820

◆ normalize()

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

Normalizes the given vector.

Definition at line 277 of file shz_vector.hpp.

277 {
278 *static_cast<CppType*>(this) = shz_vec_normalize(*static_cast<const CppType*>(this));
279 }

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

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

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

287 {
288 *static_cast<CppType*>(this) = shz_vec_normalize_safe(*static_cast<const CppType*>(this));
289 }

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

292 {
293 return shz_vec_distance(*static_cast<const CppType*>(this), other);
294 }
#define shz_vec_distance(vec1, vec2)
C type-generic vector distance.
Definition shz_vector.h:834

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

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

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

302 {
303 return shz_vec_move(*static_cast<const CppType*>(this), target, maxdist);
304 }
#define shz_vec_move(vec, target, maxdist)
C type-generic vector move.
Definition shz_vector.h:841

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

307 {
308 return shz_vec_reflect(*static_cast<const CppType*>(this), normal);
309 }
#define shz_vec_reflect(incidence, normal)
C type-generic vector reflection.
Definition shz_vector.h:862

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

312 {
313 return shz_vec_refract(*static_cast<const CppType*>(this), normal, eta);
314 }
#define shz_vec_refract(incidence, normal, eta)
C type-generic vector refraction.
Definition shz_vector.h:869

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

317 {
318 return shz_vec_project(*static_cast<const CppType*>(this), onto);
319 }
#define shz_vec_project(vec1, vec2)
C type-generic vector projection.
Definition shz_vector.h:882

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

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

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

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

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

332 {
333 return shz_vec_angles(*static_cast<const CppType*>(this));
334 }
#define shz_vec_angles(vec)
C type-generic angle-from-vector extraction.
Definition shz_vector.h:896

Friends And Related Symbol Documentation

◆ operator==

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

Overloaded equality operator, for comparing vectors.

Definition at line 124 of file shz_vector.hpp.

124 {
125 return shz_vec_equal(lhs, rhs);
126 }
#define shz_vec_equal(vec1, vec2)
C type-generic vector equals.
Definition shz_vector.h:736

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

129 {
130 return vec.neg();
131 }
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: