cpp-sdl2
C++ header-only SDL2 wrapper
|
Generic templated 2D vector class. More...
#include <vec2.hpp>
Public Member Functions | |
constexpr | Vec2 () |
ctor, that will initialize vector to null vector More... | |
constexpr | Vec2 (T x, T y) |
ctor that will initialize it to the current value More... | |
constexpr | Vec2 (SDL_Point const &p) |
Convert SDL_Point to sdl::Vec2. More... | |
constexpr | Vec2 (Vec2 const &) noexcept=default |
constexpr | Vec2 (Vec2 &&) noexcept=default |
Vec2 & | operator= (Vec2 const &) noexcept=default |
Vec2 & | operator= (Vec2 &&) noexcept=default |
constexpr Vec2 | operator- () const |
Return the opposite vector. More... | |
Vec2 & | operator+= (Vec2 const &other) |
Add vector to this one. More... | |
Vec2 & | operator-= (Vec2 const &other) |
Substract vector to this one. More... | |
Vec2 & | operator*= (T value) |
Multiply vector to this one (x1*x2, y1*y2) More... | |
Vec2 & | operator/= (T value) |
Divide vector to this one (x1/x2, y1/y2) More... | |
constexpr Vec2 | operator+ (Vec2 const &other) const |
Add vectors together. More... | |
constexpr Vec2 | operator- (Vec2 const &other) const |
Substract vectors together. More... | |
constexpr Vec2 | operator* (T value) const |
Multiply vectors together. More... | |
constexpr Vec2 | operator/ (T value) const |
Divide vectors together. More... | |
constexpr bool | operator== (Vec2 const &other) const |
Compare vectors, true if they are the same. More... | |
constexpr bool | operator!= (Vec2 const &other) const |
Compare vectors, false if they are the same. More... | |
Vec2 | clamped (SDL_Rect const &box) const |
Clamp vector inside a box rectangle were to clamp vector. More... | |
void | clamp (SDL_Rect const &box) |
Clamp vector inside a box rectangle were to clamp vector. More... | |
T | length () const |
Get lenghts of this vector. More... | |
T | sqlength () const |
Get squared lenght of this vector. More... | |
bool | is_null () const |
Return true if this vector is null. More... | |
Vec2 | normalized () const |
Return normalized copy of this vector. More... | |
void | normalize () |
Normalize this vector. More... | |
template<typename U > | |
operator Vec2< U > () const | |
Convert this vectort to a vector of <U> type. More... | |
Static Public Member Functions | |
template<typename A > | |
static constexpr Vec2 | from_polar (A alpha, T radius) |
Convert a vector in polar cordinates to cartesian in the 2D plan. More... | |
Private Member Functions | |
T | clamp (T x, T a, T b) |
Actual implementation of clamp function. More... | |
Friends | |
constexpr Vec2 | operator* (T lhs, Vec2 const &rhs) |
Multiply operator that works on the other side. More... | |
std::ostream & | operator<< (std::ostream &stream, Vec2 const &v) |
Print that vector to stream. More... | |
Generic templated 2D vector class.
|
inline |
ctor that will initialize it to the current value
Definition at line 30 of file vec2.hpp.
References sdl::details::Vec2Base< T >::x.
|
defaultnoexcept |
|
defaultnoexcept |
|
inline |
Clamp vector inside a box rectangle were to clamp vector.
Definition at line 109 of file vec2.hpp.
Referenced by sdl::Vec2< T, Base >::clamped().
|
inlineprivate |
|
inline |
Clamp vector inside a box rectangle were to clamp vector.
Definition at line 101 of file vec2.hpp.
References sdl::Vec2< T, Base >::clamp().
|
inline |
|
inline |
|
inline |
Normalize this vector.
Definition at line 132 of file vec2.hpp.
Referenced by sdl::Vec2< T, Base >::normalized().
|
inline |
Return normalized copy of this vector.
Definition at line 124 of file vec2.hpp.
References sdl::Vec2< T, Base >::normalize().
|
defaultnoexcept |
|
defaultnoexcept |
|
inline |
|
friend |