jaulib v1.4.0-2-g788cf73
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}, component wise.
 
constexpr Vector2Iadd (const Vector2I &d) noexcept
 this = this + {d.x, d.y}, component wise.
 
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.
 
size_t hashCode () const noexcept
 TODO constexpr bool operator<=>(const vec2i_t& rhs ) const noexcept { return ... }.
 
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}, component wise.
 
constexpr Vector2Imul (const Vector2I &s) noexcept
 this = this * {s.x, s.y}, component wise.
 
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
 this = this * s, component wise.
 
constexpr Vector2Ioperator*= (const Vector2I &s) noexcept
 this = this * {s.x, s.y}, component wise.
 
constexpr Vector2Ioperator+= (const Vector2I &rhs) noexcept
 this = this + rhs, component wise.
 
constexpr Vector2Ioperator-= (const Vector2I &rhs) noexcept
 this = this - rhs, component wise.
 
constexpr Vector2Ioperator/= (const value_type s) noexcept
 this = this * s, component wise.
 
constexpr Vector2Ioperator/= (const Vector2I &s) noexcept
 this = this / {s.x, s.y}, component wise.
 
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, component wise.
 
constexpr Vector2Iset (const value_type vx, const value_type vy) noexcept
 
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<jau::req::packed_integral Value_type>
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 39 of file vec2i.hpp.

Member Typedef Documentation

◆ value_type

template<jau::req::packed_integral Value_type>
typedef Value_type jau::math::Vector2I< Value_type >::value_type

Definition at line 41 of file vec2i.hpp.

◆ pointer

template<jau::req::packed_integral Value_type>
typedef value_type* jau::math::Vector2I< Value_type >::pointer

Definition at line 42 of file vec2i.hpp.

◆ const_pointer

template<jau::req::packed_integral Value_type>
typedef const value_type* jau::math::Vector2I< Value_type >::const_pointer

Definition at line 43 of file vec2i.hpp.

◆ reference

template<jau::req::packed_integral Value_type>
typedef value_type& jau::math::Vector2I< Value_type >::reference

Definition at line 44 of file vec2i.hpp.

◆ const_reference

template<jau::req::packed_integral Value_type>
typedef const value_type& jau::math::Vector2I< Value_type >::const_reference

Definition at line 45 of file vec2i.hpp.

◆ iterator

template<jau::req::packed_integral Value_type>
typedef value_type* jau::math::Vector2I< Value_type >::iterator

Definition at line 46 of file vec2i.hpp.

◆ const_iterator

template<jau::req::packed_integral Value_type>
typedef const value_type* jau::math::Vector2I< Value_type >::const_iterator

Definition at line 47 of file vec2i.hpp.

◆ float_type

template<jau::req::packed_integral Value_type>
typedef jau::float_bytes<sizeof(value_type)>::type jau::math::Vector2I< Value_type >::float_type

Definition at line 58 of file vec2i.hpp.

Constructor & Destructor Documentation

◆ Vector2I() [1/5]

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::Vector2I ( )
inlineconstexprnoexcept

Definition at line 66 of file vec2i.hpp.

Here is the caller graph for this function:

◆ Vector2I() [2/5]

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::Vector2I ( const value_type v)
inlineconstexprnoexcept

Definition at line 69 of file vec2i.hpp.

◆ Vector2I() [3/5]

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::Vector2I ( const value_type x_,
const value_type y_ )
inlineconstexprnoexcept

Definition at line 72 of file vec2i.hpp.

◆ Vector2I() [4/5]

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::Vector2I ( const Vector2I< Value_type > & o)
constexprdefaultnoexcept

◆ Vector2I() [5/5]

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::Vector2I ( Vector2I< Value_type > && o)
constexprdefaultnoexcept

Member Function Documentation

◆ operator=() [1/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator= ( const Vector2I< Value_type > & )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator= ( Vector2I< Value_type > && )
constexprdefaultnoexcept

◆ copy()

template<jau::req::packed_integral Value_type>
Vector2I jau::math::Vector2I< Value_type >::copy ( )
inlineconstexprnoexcept

Definition at line 80 of file vec2i.hpp.

◆ operator[]() [1/2]

template<jau::req::packed_integral Value_type>
value_type jau::math::Vector2I< Value_type >::operator[] ( size_t i) const
inlineconstexprnoexcept

Returns read-only component.

Definition at line 83 of file vec2i.hpp.

◆ operator const_pointer()

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::operator const_pointer ( ) const
inlineexplicitnoexcept

Definition at line 88 of file vec2i.hpp.

◆ cbegin()

template<jau::req::packed_integral Value_type>
const_iterator jau::math::Vector2I< Value_type >::cbegin ( ) const
inlineconstexprnoexcept

Definition at line 89 of file vec2i.hpp.

◆ operator[]() [2/2]

template<jau::req::packed_integral Value_type>
reference jau::math::Vector2I< Value_type >::operator[] ( size_t i)
inlineconstexprnoexcept

Returns writeable reference to component.

Definition at line 92 of file vec2i.hpp.

◆ operator pointer()

template<jau::req::packed_integral Value_type>
jau::math::Vector2I< Value_type >::operator pointer ( )
inlineexplicitnoexcept

Definition at line 97 of file vec2i.hpp.

◆ begin()

template<jau::req::packed_integral Value_type>
iterator jau::math::Vector2I< Value_type >::begin ( )
inlineconstexprnoexcept

Definition at line 98 of file vec2i.hpp.

◆ get()

template<jau::req::packed_integral Value_type>
iterator jau::math::Vector2I< Value_type >::get ( iterator xy) const
inlineconstexprnoexcept

xy = this, returns xy.

Definition at line 101 of file vec2i.hpp.

◆ operator==()

template<jau::req::packed_integral Value_type>
bool jau::math::Vector2I< Value_type >::operator== ( const Vector2I< Value_type > & rhs) const
inlineconstexprnoexcept

Definition at line 107 of file vec2i.hpp.

◆ hashCode()

template<jau::req::packed_integral Value_type>
size_t jau::math::Vector2I< Value_type >::hashCode ( ) const
inlinenoexcept

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

Definition at line 118 of file vec2i.hpp.

◆ set() [1/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::set ( const value_type vx,
const value_type vy )
inlineconstexprnoexcept

Definition at line 124 of file vec2i.hpp.

◆ set() [2/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::set ( const_iterator xy)
inlineconstexprnoexcept

this = xy, returns this.

Definition at line 128 of file vec2i.hpp.

◆ add() [1/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::add ( const Vector2I< Value_type > & d)
inlineconstexprnoexcept

this = this + {d.x, d.y}, component wise.

Returns this.

Definition at line 132 of file vec2i.hpp.

◆ add() [2/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::add ( const value_type dx,
const value_type dy )
inlineconstexprnoexcept

this = this + {sx, sy}, component wise.

Returns this.

Definition at line 136 of file vec2i.hpp.

◆ mul() [1/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::mul ( const Vector2I< Value_type > & s)
inlineconstexprnoexcept

this = this * {s.x, s.y}, component wise.

Returns this.

Definition at line 140 of file vec2i.hpp.

◆ mul() [2/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::mul ( const value_type sx,
const value_type sy )
inlineconstexprnoexcept

this = this * {sx, sy}, component wise.

Returns this.

Definition at line 144 of file vec2i.hpp.

◆ scale()

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::scale ( const value_type s)
inlineconstexprnoexcept

this = this * s, component wise.

Returns this.

Definition at line 148 of file vec2i.hpp.

◆ operator+=()

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator+= ( const Vector2I< Value_type > & rhs)
inlineconstexprnoexcept

this = this + rhs, component wise.

Returns this.

Definition at line 152 of file vec2i.hpp.

◆ operator-=()

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator-= ( const Vector2I< Value_type > & rhs)
inlineconstexprnoexcept

this = this - rhs, component wise.

Returns this.

Definition at line 158 of file vec2i.hpp.

◆ operator*=() [1/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator*= ( const Vector2I< Value_type > & s)
inlineconstexprnoexcept

this = this * {s.x, s.y}, component wise.

Parameters
sscale factor
Returns
this instance

Definition at line 168 of file vec2i.hpp.

◆ operator/=() [1/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator/= ( const Vector2I< Value_type > & s)
inlineconstexprnoexcept

this = this / {s.x, s.y}, component wise.

Parameters
sscale factor
Returns
this instance

Definition at line 177 of file vec2i.hpp.

◆ operator*=() [2/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator*= ( const value_type s)
inlineconstexprnoexcept

this = this * s, component wise.

Parameters
sscale factor
Returns
this instance

Definition at line 187 of file vec2i.hpp.

◆ operator/=() [2/2]

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::operator/= ( const value_type s)
inlineconstexprnoexcept

this = this * s, component wise.

Parameters
sscale factor
Returns
this instance

Definition at line 197 of file vec2i.hpp.

◆ rotate() [1/2]

template<jau::req::packed_integral Value_type>
constexpr_cxx26 void jau::math::Vector2I< Value_type >::rotate ( const float_type radians,
const Vector2I< Value_type > & ctr )
inline

Definition at line 202 of file vec2i.hpp.

Here is the caller graph for this function:

◆ rotate() [2/2]

template<jau::req::packed_integral Value_type>
void jau::math::Vector2I< Value_type >::rotate ( const float_type sin,
const float_type cos,
const Vector2I< Value_type > & ctr )
inline

Definition at line 207 of file vec2i.hpp.

◆ toString()

template<jau::req::packed_integral Value_type>
std::string jau::math::Vector2I< Value_type >::toString ( ) const
inlinenoexcept

Definition at line 215 of file vec2i.hpp.

◆ is_zero()

template<jau::req::packed_integral Value_type>
bool jau::math::Vector2I< Value_type >::is_zero ( ) const
inlineconstexprnoexcept

Definition at line 217 of file vec2i.hpp.

◆ length_sq()

template<jau::req::packed_integral Value_type>
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 224 of file vec2i.hpp.

Here is the caller graph for this function:

◆ length()

template<jau::req::packed_integral Value_type>
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 231 of file vec2i.hpp.

◆ normalize()

template<jau::req::packed_integral Value_type>
Vector2I & jau::math::Vector2I< Value_type >::normalize ( )
inlineconstexprnoexcept

Normalize this vector in place, returns *this.

Definition at line 237 of file vec2i.hpp.

◆ intersects()

template<jau::req::packed_integral Value_type>
bool jau::math::Vector2I< Value_type >::intersects ( const Vector2I< Value_type > & o)
inline

Definition at line 251 of file vec2i.hpp.

Member Data Documentation

◆ value_alignment

template<jau::req::packed_integral Value_type>
int jau::math::Vector2I< Value_type >::value_alignment = sizeof(value_type)
staticconstexpr

value alignment is sizeof(value_type)

Definition at line 50 of file vec2i.hpp.

◆ components

template<jau::req::packed_integral Value_type>
const size_t jau::math::Vector2I< Value_type >::components = 2
staticconstexpr

Number of value_type components.

Definition at line 53 of file vec2i.hpp.

◆ byte_size

template<jau::req::packed_integral Value_type>
const size_t jau::math::Vector2I< Value_type >::byte_size = components * sizeof(value_type)
staticconstexpr

Size in bytes with value_alignment.

Definition at line 56 of file vec2i.hpp.

◆ zero

template<jau::req::packed_integral Value_type>
const value_type jau::math::Vector2I< Value_type >::zero = value_type(0)
staticconstexpr

Definition at line 60 of file vec2i.hpp.

◆ one

template<jau::req::packed_integral Value_type>
const value_type jau::math::Vector2I< Value_type >::one = value_type(1)
staticconstexpr

Definition at line 61 of file vec2i.hpp.

◆ x

Definition at line 63 of file vec2i.hpp.

◆ y

Definition at line 64 of file vec2i.hpp.


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