![]() |
TGX 1.0.3
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
Generic 2D vector [specializations iVec2, fVec2, dVec2]. More...
#include <Vec2.h>
Public Member Functions | |
Vec2 () | |
default constructor: the vector content is undefined. | |
constexpr | Vec2 (T X, T Y) |
Constructor with explicit initialization. | |
Vec2 (const Vec2 &v)=default | |
Default copy constructor. | |
Vec2 & | operator= (const Vec2 &V)=default |
Default assignment operator. | |
template<typename U > | |
operator Vec2< U > () | |
Explicit conversion to another vector with different integral type. More... | |
operator Vec2< typename DefaultFPType< T >::fptype > () | |
Implicit conversion to floating-point type vector. | |
bool | operator== (const Vec2 V) const |
Equality comparator. More... | |
bool | operator!= (const Vec2 V) const |
Inequality operator. | |
bool | operator< (const Vec2 V) const |
Less-than comparison operator. More... | |
bool | operator<= (const Vec2 V) const |
Less-than-or-equal comparison operator. More... | |
bool | operator> (const Vec2 V) const |
Greater-than comparison operator. More... | |
bool | operator>= (const Vec2 V) const |
Greater-than-or-equal comparison operator. More... | |
void | operator+= (const Vec2 V) |
Add another vector to this one. | |
void | operator-= (const Vec2 V) |
Substract another vector from this one. | |
void | operator*= (const Vec2 V) |
Multiply this vector by another one (coordinate by coordinate multiplication). | |
void | operator/= (const Vec2 V) |
Divide this vector by another one (coordinate by coordinate division). | |
void | operator+= (const T &v) |
scalar addition. More... | |
void | operator-= (const T &v) |
scalar substraction. More... | |
void | operator*= (const T &v) |
scalar multiplication. More... | |
void | operator/= (const T &v) |
scalar division. More... | |
Vec2 | operator- () const |
unary negation operator | |
T | norm2 () const |
Compute the squared euclidian norm of the vector. More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
Tfloat | norm () const |
Compute the euclidian norm of the vector. More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
Tfloat | norm_fast () const |
Compute the euclidian norm of the vector. More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
Tfloat | invnorm () const |
Compute the inverse of the euclidian norm of the vector. More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
Tfloat | invnorm_fast () const |
Compute the inverse of the euclidian norm of the vector. More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
void | normalize () |
Normalise the vector so that its norm is 1 (do nothing if the vector is 0). More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
void | normalize_fast () |
Normalise the vector so that its norm is 1 (do nothing if the vector is 0). More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
Vec2< T > | getNormalize () const |
Return the vector normalized to have unit norm (do nothing if the vector is 0). More... | |
template<typename Tfloat = typename DefaultFPType<T>::fptype> | |
Vec2< T > | getNormalize_fast () const |
Return the vector normalized to have unit norm (do nothing if the vector is 0). More... | |
void | rotate90 () |
Rotate this vector by +90 degree (anti-clockise). | |
Vec2< T > | getRotate90 () const |
Return the vector obtained after rotation by +90 degree (anti-clockise). | |
int | leftOf (Vec2< T > LA, Vec2< T > LB) const |
Determine which half-space delimited by the line (LA,LB) the point represented by this vector belongs. More... | |
bool | setAsIntersection (Vec2< T > LA1, Vec2< T > LA2, Vec2< T > LB1, Vec2< T > LB2) |
Set this vector as the intersection of the two lines (LA1,LA2) and (LB1,LB2). More... | |
void | print (Stream &outputStream=Serial) const |
Print a representation of the vector using a given stream object. More... | |
Public Attributes | |
T | x |
'x' coordinate (first dimension) | |
T | y |
'y' coordinate (second dimension) | |
Generic 2D vector [specializations iVec2, fVec2, dVec2].
The class contains two public member variables x
and y
which define the 2D vector (x,y)
.
`T` | arithmetic type of the vector (int , float ...) |
Explicit conversion to another vector with different integral type.
T
to type U
is performed with a simple C-style cast. Equality comparator.
Return true if all components compare equal.
Less-than comparison operator.
Use lexicographical order.
Less-than-or-equal comparison operator.
Use lexicographical order.
Greater-than comparison operator.
Use lexicographical order.
Greater-than-or-equal comparison operator.
Use lexicographical order.
|
inline |
scalar addition.
Add v to each of the vector components.
|
inline |
scalar substraction.
Add v to each of the vector components.
|
inline |
scalar multiplication.
Multiply each of the vector components by v.
|
inline |
scalar division.
Divde each of the vector components by v.
|
inline |
Compute the squared euclidian norm of the vector.
|
inline |
Compute the euclidian norm of the vector.
Tfloat | Return type also used by computation. If left unspecified, the default floating type is used. |
|
inline |
Compute the euclidian norm of the vector.
Use the tgx::fast_sqrt() approximation to speedup computations.
Tfloat | Return type also used by computation. If left unspecified, the default floating type is used. |
|
inline |
Compute the inverse of the euclidian norm of the vector.
Tfloat | Return type also used by computation. If left unspecified, the default floating type is used. |
|
inline |
Compute the inverse of the euclidian norm of the vector.
Use the tgx::fast_invsqrt() approximation to speedup computations.
Tfloat | Return type also used by computation. If left unspecified, the default floating type is used. |
|
inline |
Normalise the vector so that its norm is 1 (do nothing if the vector is 0).
Tfloat | Floating point type used for computation (use default floating point type if unspecified). |
|
inline |
Normalise the vector so that its norm is 1 (do nothing if the vector is 0).
Use fast_invsqrt() approxiamtion to speedup computations.
Tfloat | Floating point type used for computation (use default floating point type if unspecified). |
|
inline |
Return the vector normalized to have unit norm (do nothing if the vector is 0).
Tfloat | Floating point type used for computation (use default floating point type if unspecified). |
|
inline |
Return the vector normalized to have unit norm (do nothing if the vector is 0).
Use fast_invsqrt() approxiamtion to speedup computations.
Tfloat | Floating point type used for computation (use default floating point type if unspecified). |
Determine which half-space delimited by the line (LA,LB) the point represented by this vector belongs.
|
inline |
Set this vector as the intersection of the two lines (LA1,LA2) and (LB1,LB2).
If the lines are parallel, the vector is left unchanged.
|
inline |
Print a representation of the vector using a given stream object.