jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
jau::math::Vector4F< Value_type, > Class Template Reference

4D vector using four value_type components. More...

#include <vec4f.hpp>

Inheritance diagram for jau::math::Vector4F< Value_type, >:
Collaboration diagram for jau::math::Vector4F< Value_type, >:

Public Types

typedef const value_typeconst_iterator
 
typedef const value_typeconst_pointer
 
typedef const value_typeconst_reference
 
typedef value_typeiterator
 
typedef value_typepointer
 
typedef value_typereference
 
typedef Value_type value_type
 
typedef Vector3F< value_type, std::is_floating_point_v< Value_type > > Vec3
 

Public Member Functions

constexpr Vector4F () noexcept
 
constexpr Vector4F (const value_type v) noexcept
 
constexpr Vector4F (const value_type x_, const value_type y_, const value_type z_, const value_type w_) noexcept
 
constexpr Vector4F (const Vec3 &o3, const value_type w_) noexcept
 
constexpr Vector4F (const Vector4F &o) noexcept=default
 
constexpr Vector4F (const_iterator v) noexcept
 
constexpr Vector4F (std::initializer_list< value_type > v) noexcept
 
constexpr Vector4F (Vector4F &&o) noexcept=default
 
constexpr Vector4Fadd (const value_type dx, const value_type dy, const value_type dz, const value_type dw) noexcept
 this = this + {dx, dy, dz, dw}, returns this.
 
constexpr iterator begin () noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr Vector4F copy () noexcept
 
constexpr value_type dist (const Vector4F &o) const noexcept
 Return the distance between this vector and the given one.
 
constexpr value_type dist_sq (const Vector4F &o) const noexcept
 Return the squared distance between this vector and the given one.
 
constexpr iterator get (iterator xyzw) const noexcept
 xyzw = this, returns xyzw.
 
constexpr Vec3getVec3 (Vec3 &out) const noexcept
 out = { this.x, this.y, this.z } dropping w, returns out.
 
constexpr_cxx23 bool intersects (const Vector4F &o) const noexcept
 
constexpr bool is_zero () const noexcept
 
constexpr value_type length () const noexcept
 Return the length of a vector, a.k.a the norm or magnitude
 
constexpr value_type length_sq () const noexcept
 Return the squared length of a vector, a.k.a the squared norm or squared magnitude
 
constexpr Vector4Fmul (const value_type sx, const value_type sy, const value_type sz, const value_type sw) noexcept
 this = this * {sx, sy, sz, sw}, returns this.
 
constexpr Vector4Fnormalize () noexcept
 Normalize this vector in place.
 
 operator const_pointer () const noexcept
 
 operator pointer () noexcept
 
constexpr Vector4Foperator*= (const value_type s) noexcept
 Scale this vector with given scale factor.
 
constexpr Vector4Foperator+= (const Vector4F &rhs) noexcept
 this = this + rhs, returns this.
 
constexpr Vector4Foperator-= (const Vector4F &rhs) noexcept
 this = this - rhs, returns this.
 
constexpr Vector4Foperator/= (const value_type s) noexcept
 Divide this vector with given scale factor.
 
constexpr Vector4Foperator= (const Vector4F &) noexcept=default
 
constexpr Vector4Foperator= (Vector4F &&) noexcept=default
 
constexpr bool operator== (const Vector4F &rhs) const noexcept
 
constexpr value_type operator[] (size_t i) const noexcept
 Returns read-only component.
 
constexpr reference operator[] (size_t i) noexcept
 Returns writeable reference to component.
 
constexpr Vector4Fscale (const value_type s) noexcept
 this = this * s, returns this.
 
constexpr Vector4Fset (const value_type vx, const value_type vy, const value_type vz, const value_type vw) noexcept
 
constexpr Vector4Fset (const Vec3f &o, const value_type w_) noexcept
 TODO constexpr bool operator<=>(const vec4f_t& rhs ) const noexcept { return ... }.
 
constexpr Vector4Fset (const_iterator xyzw) noexcept
 this = xyzw, returns this.
 
std::string toString () const noexcept
 

Public Attributes

value_type w
 
value_type x
 
value_type y
 
value_type z
 

Static Public Attributes

static constexpr const size_t byte_size = components * sizeof(value_type)
 Size in bytes with value_alignment.
 
static constexpr const size_t components = 4
 Number of value_type components.
 
static constexpr const value_type one = value_type(1)
 
static constexpr int value_alignment = sizeof(value_type)
 value alignment is sizeof(value_type)
 
static constexpr const value_type zero = value_type(0)
 

Detailed Description

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
class jau::math::Vector4F< Value_type, >

4D vector using four value_type components.

Component and overall alignment is natural as sizeof(value_type), i.e. sizeof(value_type) == alignof(value_type)

Definition at line 57 of file vec4f.hpp.

Member Typedef Documentation

◆ value_type

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef Value_type jau::math::Vector4F< Value_type, >::value_type

Definition at line 59 of file vec4f.hpp.

◆ pointer

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef value_type* jau::math::Vector4F< Value_type, >::pointer

Definition at line 60 of file vec4f.hpp.

◆ const_pointer

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef const value_type* jau::math::Vector4F< Value_type, >::const_pointer

Definition at line 61 of file vec4f.hpp.

◆ reference

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef value_type& jau::math::Vector4F< Value_type, >::reference

Definition at line 62 of file vec4f.hpp.

◆ const_reference

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef const value_type& jau::math::Vector4F< Value_type, >::const_reference

Definition at line 63 of file vec4f.hpp.

◆ iterator

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef value_type* jau::math::Vector4F< Value_type, >::iterator

Definition at line 64 of file vec4f.hpp.

◆ const_iterator

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef const value_type* jau::math::Vector4F< Value_type, >::const_iterator

Definition at line 65 of file vec4f.hpp.

◆ Vec3

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef Vector3F<value_type, std::is_floating_point_v<Value_type> > jau::math::Vector4F< Value_type, >::Vec3

Definition at line 76 of file vec4f.hpp.

Constructor & Destructor Documentation

◆ Vector4F() [1/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( )
inlineconstexprnoexcept

Definition at line 86 of file vec4f.hpp.

Here is the caller graph for this function:

◆ Vector4F() [2/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( const value_type v)
inlineconstexprnoexcept

Definition at line 89 of file vec4f.hpp.

◆ Vector4F() [3/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( const value_type x_,
const value_type y_,
const value_type z_,
const value_type w_ )
inlineconstexprnoexcept

Definition at line 92 of file vec4f.hpp.

◆ Vector4F() [4/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( const Vec3 & o3,
const value_type w_ )
inlineconstexprnoexcept

Definition at line 95 of file vec4f.hpp.

◆ Vector4F() [5/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( const_iterator v)
inlineconstexprnoexcept

Definition at line 98 of file vec4f.hpp.

◆ Vector4F() [6/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( std::initializer_list< value_type > v)
inlineconstexprnoexcept

Definition at line 101 of file vec4f.hpp.

◆ Vector4F() [7/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( const Vector4F< Value_type, > & o)
constexprdefaultnoexcept

◆ Vector4F() [8/8]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::Vector4F ( Vector4F< Value_type, > && o)
constexprdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::operator= ( const Vector4F< Value_type, > & )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::operator= ( Vector4F< Value_type, > && )
constexprdefaultnoexcept

◆ copy()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F jau::math::Vector4F< Value_type, >::copy ( )
inlineconstexprnoexcept

Definition at line 109 of file vec4f.hpp.

◆ operator[]() [1/2]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::operator[] ( size_t i) const
inlineconstexprnoexcept

Returns read-only component.

Definition at line 112 of file vec4f.hpp.

◆ operator const_pointer()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::operator const_pointer ( ) const
inlineexplicitnoexcept

Definition at line 117 of file vec4f.hpp.

◆ cbegin()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
const_iterator jau::math::Vector4F< Value_type, >::cbegin ( ) const
inlineconstexprnoexcept

Definition at line 118 of file vec4f.hpp.

◆ operator[]() [2/2]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
reference jau::math::Vector4F< Value_type, >::operator[] ( size_t i)
inlineconstexprnoexcept

Returns writeable reference to component.

Definition at line 121 of file vec4f.hpp.

◆ operator pointer()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
jau::math::Vector4F< Value_type, >::operator pointer ( )
inlineexplicitnoexcept

Definition at line 126 of file vec4f.hpp.

◆ begin()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
iterator jau::math::Vector4F< Value_type, >::begin ( )
inlineconstexprnoexcept

Definition at line 127 of file vec4f.hpp.

◆ get()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
iterator jau::math::Vector4F< Value_type, >::get ( iterator xyzw) const
inlineconstexprnoexcept

xyzw = this, returns xyzw.

Definition at line 130 of file vec4f.hpp.

◆ getVec3()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vec3 & jau::math::Vector4F< Value_type, >::getVec3 ( Vec3 & out) const
inlineconstexprnoexcept

out = { this.x, this.y, this.z } dropping w, returns out.

Definition at line 134 of file vec4f.hpp.

Here is the caller graph for this function:

◆ operator==()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
bool jau::math::Vector4F< Value_type, >::operator== ( const Vector4F< Value_type, > & rhs) const
inlineconstexprnoexcept

Definition at line 137 of file vec4f.hpp.

◆ set() [1/3]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::set ( const Vec3f & o,
const value_type w_ )
inlineconstexprnoexcept

TODO constexpr bool operator<=>(const vec4f_t& rhs ) const noexcept { return ... }.

this = { o, w }, returns this.

Definition at line 150 of file vec4f.hpp.

Here is the caller graph for this function:

◆ set() [2/3]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::set ( const value_type vx,
const value_type vy,
const value_type vz,
const value_type vw )
inlineconstexprnoexcept

Definition at line 153 of file vec4f.hpp.

◆ set() [3/3]

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::set ( const_iterator xyzw)
inlineconstexprnoexcept

this = xyzw, returns this.

Definition at line 157 of file vec4f.hpp.

◆ add()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::add ( const value_type dx,
const value_type dy,
const value_type dz,
const value_type dw )
inlineconstexprnoexcept

this = this + {dx, dy, dz, dw}, returns this.

Definition at line 161 of file vec4f.hpp.

Here is the caller graph for this function:

◆ mul()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::mul ( const value_type sx,
const value_type sy,
const value_type sz,
const value_type sw )
inlineconstexprnoexcept

this = this * {sx, sy, sz, sw}, returns this.

Definition at line 165 of file vec4f.hpp.

Here is the caller graph for this function:

◆ scale()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::scale ( const value_type s)
inlineconstexprnoexcept

this = this * s, returns this.

Definition at line 169 of file vec4f.hpp.

Here is the caller graph for this function:

◆ operator+=()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::operator+= ( const Vector4F< Value_type, > & rhs)
inlineconstexprnoexcept

this = this + rhs, returns this.

Definition at line 173 of file vec4f.hpp.

◆ operator-=()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::operator-= ( const Vector4F< Value_type, > & rhs)
inlineconstexprnoexcept

this = this - rhs, returns this.

Definition at line 179 of file vec4f.hpp.

◆ operator*=()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::operator*= ( const value_type s)
inlineconstexprnoexcept

Scale this vector with given scale factor.

Parameters
sscale factor
Returns
this instance

Definition at line 188 of file vec4f.hpp.

◆ operator/=()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::operator/= ( const value_type s)
inlineconstexprnoexcept

Divide this vector with given scale factor.

Parameters
sscale factor
Returns
this instance

Definition at line 196 of file vec4f.hpp.

◆ toString()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
std::string jau::math::Vector4F< Value_type, >::toString ( ) const
inlinenoexcept

Definition at line 199 of file vec4f.hpp.

◆ is_zero()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
bool jau::math::Vector4F< Value_type, >::is_zero ( ) const
inlineconstexprnoexcept

Definition at line 201 of file vec4f.hpp.

◆ length_sq()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::length_sq ( ) const
inlineconstexprnoexcept

Return the squared length of a vector, a.k.a the squared norm or squared magnitude

Definition at line 208 of file vec4f.hpp.

Here is the caller graph for this function:

◆ length()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::length ( ) const
inlineconstexprnoexcept

Return the length of a vector, a.k.a the norm or magnitude

Definition at line 215 of file vec4f.hpp.

◆ normalize()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector4F & jau::math::Vector4F< Value_type, >::normalize ( )
inlineconstexprnoexcept

Normalize this vector in place.

Definition at line 222 of file vec4f.hpp.

◆ dist_sq()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::dist_sq ( const Vector4F< Value_type, > & o) const
inlineconstexprnoexcept

Return the squared distance between this vector and the given one.

When comparing the relative distance between two points it is usually sufficient to compare the squared distances, thus avoiding an expensive square root operation.

Definition at line 246 of file vec4f.hpp.

Here is the caller graph for this function:

◆ dist()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::dist ( const Vector4F< Value_type, > & o) const
inlineconstexprnoexcept

Return the distance between this vector and the given one.

Definition at line 257 of file vec4f.hpp.

◆ intersects()

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
constexpr_cxx23 bool jau::math::Vector4F< Value_type, >::intersects ( const Vector4F< Value_type, > & o) const
inlinenoexcept

Definition at line 261 of file vec4f.hpp.

Member Data Documentation

◆ value_alignment

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
int jau::math::Vector4F< Value_type, >::value_alignment = sizeof(value_type)
staticconstexpr

value alignment is sizeof(value_type)

Definition at line 68 of file vec4f.hpp.

◆ components

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
const size_t jau::math::Vector4F< Value_type, >::components = 4
staticconstexpr

Number of value_type components.

Definition at line 71 of file vec4f.hpp.

◆ byte_size

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
const size_t jau::math::Vector4F< Value_type, >::byte_size = components * sizeof(value_type)
staticconstexpr

Size in bytes with value_alignment.

Definition at line 74 of file vec4f.hpp.

◆ zero

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
const value_type jau::math::Vector4F< Value_type, >::zero = value_type(0)
staticconstexpr

Definition at line 78 of file vec4f.hpp.

◆ one

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
const value_type jau::math::Vector4F< Value_type, >::one = value_type(1)
staticconstexpr

Definition at line 79 of file vec4f.hpp.

◆ x

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::x

Definition at line 81 of file vec4f.hpp.

◆ y

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::y

Definition at line 82 of file vec4f.hpp.

◆ z

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::z

Definition at line 83 of file vec4f.hpp.

◆ w

template<typename Value_type, std::enable_if_t< std::is_floating_point_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector4F< Value_type, >::w

Definition at line 84 of file vec4f.hpp.


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