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

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

#include <vec2i.hpp>

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

Public Types

typedef const value_typeconst_iterator
 
typedef const value_typeconst_pointer
 
typedef const value_typeconst_reference
 
typedef jau::float_bytes< sizeof(value_type)>::type float_type
 
typedef value_typeiterator
 
typedef value_typepointer
 
typedef value_typereference
 
typedef Value_type value_type
 

Public Member Functions

constexpr Vector2I () noexcept
 
constexpr Vector2I (const value_type v) noexcept
 
constexpr Vector2I (const value_type x_, const value_type y_) noexcept
 
constexpr Vector2I (const Vector2I &o) noexcept=default
 
constexpr Vector2I (Vector2I &&o) noexcept=default
 
constexpr Vector2Iadd (const value_type dx, const value_type dy) noexcept
 this = this + {sx, sy}, returns this.
 
constexpr iterator begin () noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr Vector2I copy () noexcept
 
constexpr iterator get (iterator xy) const noexcept
 xy = this, returns xy.
 
bool intersects (const Vector2I &o)
 
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
 
constexpr value_type length_sq () const noexcept
 Return the squared length of this vector, a.k.a the squared norm or squared magnitude
 
constexpr Vector2Imul (const value_type sx, const value_type sy) noexcept
 this = this * {sx, sy}, returns this.
 
constexpr Vector2Inormalize () noexcept
 Normalize this vector in place, returns *this.
 
 operator const_pointer () const noexcept
 
 operator pointer () noexcept
 
constexpr Vector2Ioperator*= (const value_type s) noexcept
 Scale this vector with given scale factor.
 
constexpr Vector2Ioperator+= (const Vector2I &rhs) noexcept
 this = this + rhs, returns this.
 
constexpr Vector2Ioperator-= (const Vector2I &rhs) noexcept
 this = this - rhs, returns this.
 
constexpr Vector2Ioperator/= (const value_type s) noexcept
 Divide this vector with given scale factor.
 
constexpr Vector2Ioperator= (const Vector2I &) noexcept=default
 
constexpr Vector2Ioperator= (Vector2I &&) noexcept=default
 
constexpr bool operator== (const Vector2I &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_cxx26 void rotate (const float_type radians, const Vector2I &ctr)
 
void rotate (const float_type sin, const float_type cos, const Vector2I &ctr)
 
constexpr Vector2Iscale (const value_type s) noexcept
 this = this * s, returns this.
 
constexpr Vector2Iset (const value_type vx, const value_type vy) noexcept
 TODO constexpr bool operator<=>(const vec2i_t& rhs ) const noexcept { return ... }.
 
constexpr Vector2Iset (const_iterator xy) noexcept
 this = xy, returns this.
 
std::string toString () const 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 with value_alignment.
 
static constexpr const size_t components = 2
 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_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
class jau::math::Vector2I< Value_type, >

2D vector using two value_type components.

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

Definition at line 53 of file vec2i.hpp.

Member Typedef Documentation

◆ value_type

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

Definition at line 55 of file vec2i.hpp.

◆ pointer

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

Definition at line 56 of file vec2i.hpp.

◆ const_pointer

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

Definition at line 57 of file vec2i.hpp.

◆ reference

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

Definition at line 58 of file vec2i.hpp.

◆ const_reference

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

Definition at line 59 of file vec2i.hpp.

◆ iterator

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

Definition at line 60 of file vec2i.hpp.

◆ const_iterator

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

Definition at line 61 of file vec2i.hpp.

◆ float_type

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
typedef jau::float_bytes<sizeof(value_type)>::type jau::math::Vector2I< Value_type, >::float_type

Definition at line 72 of file vec2i.hpp.

Constructor & Destructor Documentation

◆ Vector2I() [1/5]

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

Definition at line 80 of file vec2i.hpp.

Here is the caller graph for this function:

◆ Vector2I() [2/5]

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

Definition at line 83 of file vec2i.hpp.

◆ Vector2I() [3/5]

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

Definition at line 86 of file vec2i.hpp.

◆ Vector2I() [4/5]

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

◆ Vector2I() [5/5]

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

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ copy()

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

Definition at line 94 of file vec2i.hpp.

◆ operator[]() [1/2]

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

Returns read-only component.

Definition at line 97 of file vec2i.hpp.

◆ operator const_pointer()

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

Definition at line 102 of file vec2i.hpp.

◆ cbegin()

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

Definition at line 103 of file vec2i.hpp.

◆ operator[]() [2/2]

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

Returns writeable reference to component.

Definition at line 106 of file vec2i.hpp.

◆ operator pointer()

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

Definition at line 111 of file vec2i.hpp.

◆ begin()

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

Definition at line 112 of file vec2i.hpp.

◆ get()

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
iterator jau::math::Vector2I< Value_type, >::get ( iterator xy) const
inlineconstexprnoexcept

xy = this, returns xy.

Definition at line 115 of file vec2i.hpp.

◆ operator==()

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

Definition at line 121 of file vec2i.hpp.

◆ set() [1/2]

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

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

Definition at line 132 of file vec2i.hpp.

◆ set() [2/2]

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
Vector2I & jau::math::Vector2I< Value_type, >::set ( const_iterator xy)
inlineconstexprnoexcept

this = xy, returns this.

Definition at line 136 of file vec2i.hpp.

◆ add()

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

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

Definition at line 140 of file vec2i.hpp.

◆ mul()

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

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

Definition at line 144 of file vec2i.hpp.

◆ scale()

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

this = this * s, returns this.

Definition at line 148 of file vec2i.hpp.

◆ operator+=()

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

this = this + rhs, returns this.

Definition at line 152 of file vec2i.hpp.

◆ operator-=()

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

this = this - rhs, returns this.

Definition at line 158 of file vec2i.hpp.

◆ operator*=()

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

Scale this vector with given scale factor.

Parameters
sscale factor
Returns
this instance

Definition at line 168 of file vec2i.hpp.

◆ operator/=()

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

Divide this vector with given scale factor.

Parameters
sscale factor
Returns
this instance

Definition at line 178 of file vec2i.hpp.

◆ rotate() [1/2]

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
constexpr_cxx26 void jau::math::Vector2I< Value_type, >::rotate ( const float_type radians,
const Vector2I< Value_type, > & ctr )
inline

Definition at line 183 of file vec2i.hpp.

Here is the caller graph for this function:

◆ rotate() [2/2]

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
void jau::math::Vector2I< Value_type, >::rotate ( const float_type sin,
const float_type cos,
const Vector2I< Value_type, > & ctr )
inline

Definition at line 188 of file vec2i.hpp.

◆ toString()

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

Definition at line 196 of file vec2i.hpp.

◆ is_zero()

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

Definition at line 198 of file vec2i.hpp.

◆ length_sq()

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
value_type jau::math::Vector2I< 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 205 of file vec2i.hpp.

Here is the caller graph for this function:

◆ length()

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

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

Definition at line 212 of file vec2i.hpp.

◆ normalize()

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

Normalize this vector in place, returns *this.

Definition at line 218 of file vec2i.hpp.

◆ intersects()

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
bool jau::math::Vector2I< Value_type, >::intersects ( const Vector2I< Value_type, > & o)
inline

Definition at line 232 of file vec2i.hpp.

Member Data Documentation

◆ value_alignment

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

value alignment is sizeof(value_type)

Definition at line 64 of file vec2i.hpp.

◆ components

template<typename Value_type, std::enable_if_t< std::is_integral_v< Value_type > &&sizeof(Value_type)==alignof(Value_type), bool > = true>
const size_t jau::math::Vector2I< Value_type, >::components = 2
staticconstexpr

Number of value_type components.

Definition at line 67 of file vec2i.hpp.

◆ byte_size

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

Size in bytes with value_alignment.

Definition at line 70 of file vec2i.hpp.

◆ zero

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

Definition at line 74 of file vec2i.hpp.

◆ one

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

Definition at line 75 of file vec2i.hpp.

◆ x

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

Definition at line 77 of file vec2i.hpp.

◆ y

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

Definition at line 78 of file vec2i.hpp.


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