SH4ZAM! 0.7.0
Fast math library for the Sega Dreamcast's SH4 CPU
Loading...
Searching...
No Matches
shz::vec4 Struct Reference

#include <shz_vector.hpp>

Inheritance diagram for shz::vec4:
Collaboration diagram for shz::vec4:

Public Member Functions

 vec4 ()=default
 
 vec4 (const shz_vec4_t &other) noexcept
 
 vec4 (float v) noexcept
 
 vec4 (float x, float y, float z, float w) noexcept
 
 vec4 (const shz::vec2 &xy, float z, float w) noexcept
 
 vec4 (float x, const shz::vec2 &yz, float w) noexcept
 
 vec4 (float x, float y, const shz::vec2 &zw) noexcept
 
 vec4 (const shz::vec2 &xy, const shz::vec2 &zw) noexcept
 
 vec4 (const shz::vec3 &xyz, float w) noexcept
 
 vec4 (float x, const shz::vec3 &yzw) noexcept
 
vec2 xy () const noexcept
 
vec2 zw () const noexcept
 
vec3 xyz () const noexcept
 
 vecN () noexcept=default
 
 vecN (const vecN &other) noexcept=default
 
 vecN (const CType &other) noexcept
 
 vecN (const volatile CType &other) 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
 
- Public Member Functions inherited from shz::vecN< vec4, shz_vec4_t, 4 >
 vecN () noexcept=default
 
 vecN (const vecN &other) noexcept=default
 
 vecN (const CType &other) noexcept
 
 vecN (const volatile CType &other) noexcept
 
to () const noexcept
 
CppTypederef (const auto *raw) noexcept
 
CppTypeoperator+= (const CppType &other) noexcept
 
CppTypeoperator-= (const CppType &other) noexcept
 
CppTypeoperator*= (const CppType &other) noexcept
 
CppTypeoperator*= (float other) noexcept
 
CppTypeoperator/= (const CppType &other) noexcept
 
CppTypeoperator/= (float other) noexcept
 
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
 

Additional Inherited Members

- Public Types inherited from shz::vecN< vec4, shz_vec4_t, 4 >
using CppType
 
using CType
 
- Static Public Member Functions inherited from shz::vecN< vec4, shz_vec4_t, 4 >
static CppType from (const auto &raw) noexcept
 
static CppType lerp (const CppType &start, const CppType &end, float t) noexcept
 
static CppType step (const CppType &vec, T &&edge) noexcept
 
static CppType smoothstep (const CppType &vec, T &&edge0, T &&edge1) noexcept
 
static CppType smoothstep_safe (const CppType &vec, T &&edge0, T &&edge1) noexcept
 
- Data Fields inherited from shz_vec4_t
union { 
 
   float   e [4] 
 
   struct { 
 
      union { 
 
         struct { 
 
            float   x 
 
            float   y 
 
            float   z 
 
         }  
 
         shz_vec3_t   xyz 
 
      }  
 
      float   w 
 
   }  
 
   struct { 
 
      shz_vec2_t   xy 
 
      shz_vec2_t   zw 
 
   }  
 
};  
 
- Static Public Attributes inherited from shz::vecN< vec4, shz_vec4_t, 4 >
static constexpr size_t Rows
 
static constexpr size_t Cols
 

Detailed Description

4D Vector type

C++ structure for representing a 4-dimensional vector.

See also
shz::vecN, shz_vec4_t, shz::vec2, shz::vec3

Definition at line 569 of file shz_vector.hpp.

Constructor & Destructor Documentation

◆ vec4() [1/10]

shz::vec4::vec4 ( )
default

Default constructor: does nothing.

◆ vec4() [2/10]

shz::vec4::vec4 ( const shz_vec4_t & other)
inlinenoexcept

C Constructor: initializes a C++ shz::vec4 from a C shz_vec4_t.

Definition at line 583 of file shz_vector.hpp.

583 :
584 vecN(other) {}
vecN() noexcept=default
Default constructor, does nothing.

◆ vec4() [3/10]

shz::vec4::vec4 ( float v)
inlinenoexcept

Single-value constructor: initializes each element to the given value.

Definition at line 587 of file shz_vector.hpp.

587 :
588 vecN(shz_vec4_fill(v)) {}
shz_vec4_t shz_vec4_fill(float v) SHZ_NOEXCEPT
Returns a 4D vector with the value of each component equal to v.

◆ vec4() [4/10]

shz::vec4::vec4 ( float x,
float y,
float z,
float w )
inlinenoexcept

Value constructor: initializes each element to its corresponding parameter value.

Definition at line 591 of file shz_vector.hpp.

591 :
592 vecN(shz_vec4_init(x, y, z, w)) {}
shz_vec4_t shz_vec4_init(float x, float y, float z, float w) SHZ_NOEXCEPT
Returns a 4D vector with the given x, y, z, and w coordinates.
float z
Z coordinate.
Definition shz_vector.h:90
float w
W coordinate.
Definition shz_vector.h:94
float x
X coordinate.
Definition shz_vector.h:88
float y
Y coordinate.
Definition shz_vector.h:89

◆ vec4() [5/10]

shz::vec4::vec4 ( const shz::vec2 & xy,
float z,
float w )
inlinenoexcept

Constructs a 4D vector with a 2D vector providing the X and Y coordinates and scalars providing Z and W.

Definition at line 595 of file shz_vector.hpp.

595 :
596 vecN(shz_vec2_vec4(xy, z, w)) {}
shz_vec4_t shz_vec2_vec4(shz_vec2_t vec, float z, float w) SHZ_NOEXCEPT
Extends a 2D vector to 4D, using z and w as the values of the Z and W components.

◆ vec4() [6/10]

shz::vec4::vec4 ( float x,
const shz::vec2 & yz,
float w )
inlinenoexcept

Constructs a 4D vector with scalars providing X and W coordinates and a 2D vector providing Y and Z.

Definition at line 599 of file shz_vector.hpp.

599 :
600 vecN(shz_vec4_init(x, yz.x, yz.y, w)) {}
float x
X coordinate.
Definition shz_vector.h:42
float y
Y coordinate.
Definition shz_vector.h:43

◆ vec4() [7/10]

shz::vec4::vec4 ( float x,
float y,
const shz::vec2 & zw )
inlinenoexcept

Constructs a 4D vector with scalars providing X and Y coordinaets and a 2D vector providing Z and W.

Definition at line 603 of file shz_vector.hpp.

603 :
604 vecN(shz_vec4_init(x, y, zw.x, zw.y )) {}

◆ vec4() [8/10]

shz::vec4::vec4 ( const shz::vec2 & xy,
const shz::vec2 & zw )
inlinenoexcept

Constructs a 4D vector from the components provided by the given pair of 2D vectors.

Definition at line 607 of file shz_vector.hpp.

607 :
608 vecN(shz_vec4_init(xy.x, xy.y, zw.x, zw.y)) {}

◆ vec4() [9/10]

shz::vec4::vec4 ( const shz::vec3 & xyz,
float w )
inlinenoexcept

Constructs a 4D vector with the X, Y, and Z components given by a 3D vector and W given by a scalar.

Definition at line 611 of file shz_vector.hpp.

611 :
612 vecN(shz_vec3_vec4(xyz, w)) {}
shz_vec4_t shz_vec3_vec4(shz_vec3_t vec, float w) SHZ_NOEXCEPT
Extends a 3D vector to 4D, using w as the value of the W component.

◆ vec4() [10/10]

shz::vec4::vec4 ( float x,
const shz::vec3 & yzw )
inlinenoexcept

Constructs a 4D vector with the X component given by a scalar and the Y, Z, and W components given by a 3D vector.

Definition at line 615 of file shz_vector.hpp.

615 :
616 vecN(shz_vec4_init(x, yzw.x, yzw.y, yzw.z)) {}
float y
Y coordinate.
Definition shz_vector.h:64
float x
X coordinate.
Definition shz_vector.h:63
float z
Z coordinate.
Definition shz_vector.h:68

Member Function Documentation

◆ xy()

vec2 shz::vec4::xy ( ) const
inlinenoexcept

Definition at line 619 of file shz_vector.hpp.

619 {
620 return shz_vec4_t::xy;
621 }
shz_vec2_t xy
<X, Y> coordinates as a 2D vector
Definition shz_vector.h:97

◆ zw()

vec2 shz::vec4::zw ( ) const
inlinenoexcept

Definition at line 624 of file shz_vector.hpp.

624 {
625 return shz_vec4_t::zw;
626 }
shz_vec2_t zw
<Z, W> coordinates as a 2D vector
Definition shz_vector.h:98

◆ xyz()

vec3 shz::vec4::xyz ( ) const
inlinenoexcept

Definition at line 629 of file shz_vector.hpp.

629 {
630 return shz_vec4_t::xyz;
631 }
shz_vec3_t xyz
<X, Y, Z> coordinates as a 3D vector
Definition shz_vector.h:92

◆ vecN() [1/4]

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

Default constructor, does nothing.

◆ vecN() [2/4]

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

Default copy constructor.

◆ vecN() [3/4]

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) {}

◆ vecN() [4/4]

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)) {}

◆ dot() [1/3]

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]

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 260 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]

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 263 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

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