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

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 (CppType start, CppType end, float t) noexcept
 
static CppType step (CppType vec, T edge) noexcept
 
static CppType smoothstep (CppType vec, T edge0, T edge1) noexcept
 
static CppType smoothstep_safe (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 544 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 ( shz_vec4_t other)
inlinenoexcept

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

Definition at line 555 of file shz_vector.hpp.

555 :
556 vecN(other) {}
vecN()=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 559 of file shz_vector.hpp.

559 :
560 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 563 of file shz_vector.hpp.

563 :
564 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 ( 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 567 of file shz_vector.hpp.

567 :
568 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,
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 571 of file shz_vector.hpp.

571 :
572 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,
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 575 of file shz_vector.hpp.

575 :
576 vecN(shz_vec4_init(x, y, zw.x, zw.y )) {}

◆ vec4() [8/10]

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

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

Definition at line 579 of file shz_vector.hpp.

579 :
580 vecN(shz_vec4_init(xy.x, xy.y, zw.x, zw.y)) {}

◆ vec4() [9/10]

shz::vec4::vec4 ( 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 583 of file shz_vector.hpp.

583 :
584 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,
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 587 of file shz_vector.hpp.

587 :
588 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 591 of file shz_vector.hpp.

591 {
592 return shz_vec4_t::xy;
593 }
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 596 of file shz_vector.hpp.

596 {
597 return shz_vec4_t::zw;
598 }
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 601 of file shz_vector.hpp.

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

◆ vecN() [1/2]

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

Default constructor, does nothing.

◆ vecN() [2/2]

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

◆ dot() [1/3]

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]

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

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

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