jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
jau::math::Vector2F< Value_type, > Class Template Reference

2D vector using two value_type components. More...

#include <vec2f.hpp>

Inheritance diagram for jau::math::Vector2F< Value_type, >:
Collaboration diagram for jau::math::Vector2F< 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
 

Public Member Functions

constexpr Vector2F () noexcept
 
constexpr Vector2F (const value_type v) noexcept
 
constexpr Vector2F (const value_type x_, const value_type y_) noexcept
 
constexpr Vector2F (const Vector2F &o) noexcept=default
 
constexpr Vector2F (Vector2F &&o) noexcept=default
 
constexpr Vector2Fadd (const value_type dx, const value_type dy) noexcept
 this = this + {sx, sy}, returns this. More...
 
constexpr_cxx26 value_type angle () const noexcept
 Return the direction angle of this vector in radians. More...
 
constexpr_cxx26 value_type angle (const Vector2F &o) const noexcept
 Return the angle between two vectors in radians. More...
 
constexpr iterator begin () noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr value_type cos_angle (const Vector2F &o) const noexcept
 Return the cosines of the angle between two vectors. More...
 
constexpr value_type cross (const Vector2F &o) const noexcept
 Returns cross product of this vectors and the given one, i.e. More...
 
constexpr value_type dist (const Vector2F &o) const noexcept
 Return the distance between this vector and the given one. More...
 
constexpr value_type dist_sq (const Vector2F &o) const noexcept
 Return the squared distance between this vector and the given one. More...
 
constexpr value_type dot (const Vector2F &o) const noexcept
 Return the dot product of this vector and the given one. More...
 
constexpr iterator get (iterator xy) const noexcept
 xy = this, returns xy. More...
 
constexpr_cxx23 bool intersects (const Vector2F &o) const noexcept
 
constexpr bool is_zero () const noexcept
 
constexpr value_type length () const noexcept
 Return the length of this vector, a.k.a the norm or magnitude More...
 
constexpr value_type length_sq () const noexcept
 Return the squared length of this vector, a.k.a the squared norm or squared magnitude More...
 
constexpr Vector2Fmul (const value_type sx, const value_type sy) noexcept
 this = this * {sx, sy}, returns this. More...
 
constexpr Vector2F normal_ccw () const noexcept
 Return the counter-clock-wise (CCW) normal of this vector, i.e. More...
 
constexpr Vector2Fnormalize () noexcept
 Normalize this vector in place, returns *this. More...
 
 operator const_pointer () const noexcept
 
 operator pointer () noexcept
 
constexpr Vector2Foperator*= (const value_type s) noexcept
 Scale this vector with given scale factor. More...
 
constexpr Vector2Foperator+= (const Vector2F &rhs) noexcept
 this = this + rhs, returns this. More...
 
constexpr Vector2Foperator-= (const Vector2F &rhs) noexcept
 this = this - rhs, returns this. More...
 
constexpr Vector2Foperator/= (const value_type s) noexcept
 Divide this vector with given scale factor. More...
 
constexpr Vector2Foperator= (const Vector2F &) noexcept=default
 
constexpr Vector2Foperator= (Vector2F &&) noexcept=default
 
constexpr bool operator== (const Vector2F &rhs) const noexcept
 
constexpr value_type operator[] (size_t i) const noexcept
 Returns read-only component. More...
 
constexpr reference operator[] (size_t i) noexcept
 Returns writeable reference to component. More...
 
constexpr_cxx26 Vector2Frotate (const value_type radians) noexcept
 Rotates this vector in place, returns *this. More...
 
constexpr_cxx26 Vector2Frotate (const value_type radians, const Vector2F &ctr) noexcept
 Rotates this vector in place, returns *this. More...
 
constexpr Vector2Frotate (const value_type sin, const value_type cos) noexcept
 Rotates this vector in place, returns *this. More...
 
constexpr Vector2Frotate (const value_type sin, const value_type cos, const Vector2F &ctr) noexcept
 Rotates this vector in place, returns *this. More...
 
constexpr Vector2Fscale (const value_type s) noexcept
 this = this * s, returns this. More...
 
constexpr Vector2Fset (const value_type vx, const value_type vy) noexcept
 TODO constexpr bool operator<=>(const vec2f_t& rhs ) const noexcept { return ... }. More...
 
constexpr Vector2Fset (const_iterator xy) noexcept
 this = xy, returns this. More...
 
std::string toString () const noexcept
 

Static Public Member Functions

static constexpr_cxx26 Vector2F from_length_angle (const value_type magnitude, const value_type radians) noexcept
 

Public Attributes

value_type x
 
value_type y
 

Static Public Attributes

static constexpr const size_t byte_size = components * sizeof(value_type)
 Size in bytes (aligned) More...
 
static constexpr const size_t components = 2
 Number of components
More...
 
static constexpr const value_type one = value_type(1)
 
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 >, bool > = true>
class jau::math::Vector2F< Value_type, >

2D vector using two value_type components.

Definition at line 49 of file vec2f.hpp.

Member Typedef Documentation

◆ value_type

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef Value_type jau::math::Vector2F< Value_type, >::value_type

Definition at line 51 of file vec2f.hpp.

◆ pointer

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef value_type* jau::math::Vector2F< Value_type, >::pointer

Definition at line 52 of file vec2f.hpp.

◆ const_pointer

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef const value_type* jau::math::Vector2F< Value_type, >::const_pointer

Definition at line 53 of file vec2f.hpp.

◆ reference

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef value_type& jau::math::Vector2F< Value_type, >::reference

Definition at line 54 of file vec2f.hpp.

◆ const_reference

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef const value_type& jau::math::Vector2F< Value_type, >::const_reference

Definition at line 55 of file vec2f.hpp.

◆ iterator

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef value_type* jau::math::Vector2F< Value_type, >::iterator

Definition at line 56 of file vec2f.hpp.

◆ const_iterator

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
typedef const value_type* jau::math::Vector2F< Value_type, >::const_iterator

Definition at line 57 of file vec2f.hpp.

Constructor & Destructor Documentation

◆ Vector2F() [1/5]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Vector2F< Value_type, >::Vector2F ( )
inlineconstexprnoexcept

Definition at line 75 of file vec2f.hpp.

◆ Vector2F() [2/5]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Vector2F< Value_type, >::Vector2F ( const value_type  v)
inlineconstexprnoexcept

Definition at line 78 of file vec2f.hpp.

◆ Vector2F() [3/5]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr jau::math::Vector2F< Value_type, >::Vector2F ( const value_type  x_,
const value_type  y_ 
)
inlineconstexprnoexcept

Definition at line 81 of file vec2f.hpp.

◆ Vector2F() [4/5]

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

◆ Vector2F() [5/5]

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

Member Function Documentation

◆ from_length_angle()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
static constexpr_cxx26 Vector2F jau::math::Vector2F< Value_type, >::from_length_angle ( const value_type  magnitude,
const value_type  radians 
)
inlinestaticnoexcept

Definition at line 71 of file vec2f.hpp.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ operator[]() [1/2]

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

Returns read-only component.

Definition at line 90 of file vec2f.hpp.

◆ operator const_pointer()

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

Definition at line 95 of file vec2f.hpp.

◆ cbegin()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const_iterator jau::math::Vector2F< Value_type, >::cbegin ( ) const
inlineconstexprnoexcept

Definition at line 96 of file vec2f.hpp.

◆ operator[]() [2/2]

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

Returns writeable reference to component.

Definition at line 99 of file vec2f.hpp.

◆ operator pointer()

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

Definition at line 104 of file vec2f.hpp.

◆ begin()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr iterator jau::math::Vector2F< Value_type, >::begin ( )
inlineconstexprnoexcept

Definition at line 105 of file vec2f.hpp.

◆ get()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr iterator jau::math::Vector2F< Value_type, >::get ( iterator  xy) const
inlineconstexprnoexcept

xy = this, returns xy.

Definition at line 108 of file vec2f.hpp.

◆ operator==()

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

Definition at line 114 of file vec2f.hpp.

◆ set() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Vector2F & jau::math::Vector2F< Value_type, >::set ( const value_type  vx,
const value_type  vy 
)
inlineconstexprnoexcept

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

Definition at line 125 of file vec2f.hpp.

◆ set() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Vector2F & jau::math::Vector2F< Value_type, >::set ( const_iterator  xy)
inlineconstexprnoexcept

this = xy, returns this.

Definition at line 129 of file vec2f.hpp.

◆ add()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Vector2F & jau::math::Vector2F< Value_type, >::add ( const value_type  dx,
const value_type  dy 
)
inlineconstexprnoexcept

this = this + {sx, sy}, returns this.

Definition at line 133 of file vec2f.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 >, bool > = true>
constexpr Vector2F & jau::math::Vector2F< Value_type, >::mul ( const value_type  sx,
const value_type  sy 
)
inlineconstexprnoexcept

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

Definition at line 137 of file vec2f.hpp.

◆ scale()

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

this = this * s, returns this.

Definition at line 141 of file vec2f.hpp.

◆ operator+=()

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

this = this + rhs, returns this.

Definition at line 145 of file vec2f.hpp.

◆ operator-=()

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

this = this - rhs, returns this.

Definition at line 151 of file vec2f.hpp.

◆ operator*=()

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

Scale this vector with given scale factor.

Parameters
sscale factor
Returns
this instance

Definition at line 161 of file vec2f.hpp.

◆ operator/=()

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

Divide this vector with given scale factor.

Parameters
sscale factor
Returns
this instance

Definition at line 171 of file vec2f.hpp.

◆ rotate() [1/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Vector2F & jau::math::Vector2F< Value_type, >::rotate ( const value_type  radians,
const Vector2F< Value_type, > &  ctr 
)
inlinenoexcept

Rotates this vector in place, returns *this.

Definition at line 177 of file vec2f.hpp.

Here is the caller graph for this function:

◆ rotate() [2/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Vector2F & jau::math::Vector2F< Value_type, >::rotate ( const value_type  sin,
const value_type  cos,
const Vector2F< Value_type, > &  ctr 
)
inlineconstexprnoexcept

Rotates this vector in place, returns *this.

Definition at line 182 of file vec2f.hpp.

◆ rotate() [3/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 Vector2F & jau::math::Vector2F< Value_type, >::rotate ( const value_type  radians)
inlinenoexcept

Rotates this vector in place, returns *this.

Definition at line 191 of file vec2f.hpp.

◆ rotate() [4/4]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Vector2F & jau::math::Vector2F< Value_type, >::rotate ( const value_type  sin,
const value_type  cos 
)
inlineconstexprnoexcept

Rotates this vector in place, returns *this.

Definition at line 196 of file vec2f.hpp.

◆ toString()

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

Definition at line 203 of file vec2f.hpp.

Here is the caller graph for this function:

◆ is_zero()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr bool jau::math::Vector2F< Value_type, >::is_zero ( ) const
inlineconstexprnoexcept

Definition at line 205 of file vec2f.hpp.

◆ length_sq()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::length_sq ( ) const
inlineconstexprnoexcept

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

Definition at line 212 of file vec2f.hpp.

◆ length()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::length ( ) const
inlineconstexprnoexcept

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

Definition at line 219 of file vec2f.hpp.

◆ normalize()

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

Normalize this vector in place, returns *this.

Definition at line 224 of file vec2f.hpp.

Here is the caller graph for this function:

◆ angle() [1/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 value_type jau::math::Vector2F< Value_type, >::angle ( ) const
inlinenoexcept

Return the direction angle of this vector in radians.

Definition at line 240 of file vec2f.hpp.

Here is the caller graph for this function:

◆ dist_sq()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::dist_sq ( const Vector2F< 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 252 of file vec2f.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 >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::dist ( const Vector2F< Value_type, > &  o) const
inlineconstexprnoexcept

Return the distance between this vector and the given one.

Definition at line 261 of file vec2f.hpp.

Here is the caller graph for this function:

◆ dot()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::dot ( const Vector2F< Value_type, > &  o) const
inlineconstexprnoexcept

Return the dot product of this vector and the given one.

Returns
the dot product as value_type

Definition at line 269 of file vec2f.hpp.

Here is the caller graph for this function:

◆ cross()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::cross ( const Vector2F< Value_type, > &  o) const
inlineconstexprnoexcept

Returns cross product of this vectors and the given one, i.e.

*this x o.

The 2D cross product is identical with the 2D perp dot product.

Returns
the resulting scalar

Definition at line 280 of file vec2f.hpp.

◆ cos_angle()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr value_type jau::math::Vector2F< Value_type, >::cos_angle ( const Vector2F< Value_type, > &  o) const
inlineconstexprnoexcept

Return the cosines of the angle between two vectors.

Definition at line 287 of file vec2f.hpp.

◆ angle() [2/2]

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr_cxx26 value_type jau::math::Vector2F< Value_type, >::angle ( const Vector2F< Value_type, > &  o) const
inlinenoexcept

Return the angle between two vectors in radians.

Definition at line 294 of file vec2f.hpp.

◆ normal_ccw()

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr Vector2F jau::math::Vector2F< Value_type, >::normal_ccw ( ) const
inlineconstexprnoexcept

Return the counter-clock-wise (CCW) normal of this vector, i.e.

perp(endicular) vector

Definition at line 301 of file vec2f.hpp.

◆ intersects()

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

Definition at line 305 of file vec2f.hpp.

Member Data Documentation

◆ zero

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Vector2F< Value_type, >::zero = value_type(0)
staticconstexpr

Definition at line 59 of file vec2f.hpp.

◆ one

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const value_type jau::math::Vector2F< Value_type, >::one = value_type(1)
staticconstexpr

Definition at line 60 of file vec2f.hpp.

◆ components

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
constexpr const size_t jau::math::Vector2F< Value_type, >::components = 2
staticconstexpr

Number of components

Definition at line 63 of file vec2f.hpp.

◆ byte_size

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

Size in bytes (aligned)

Definition at line 66 of file vec2f.hpp.

◆ x

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
value_type jau::math::Vector2F< Value_type, >::x

Definition at line 68 of file vec2f.hpp.

◆ y

template<typename Value_type , std::enable_if_t< std::is_floating_point_v< Value_type >, bool > = true>
value_type jau::math::Vector2F< Value_type, >::y

Definition at line 69 of file vec2f.hpp.


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