MyGAL
Public Member Functions | Public Attributes | Related Functions | List of all members
mygal::Vector2< T > Class Template Reference

Class representing a 2D vector. More...

#include <Vector2.h>

Public Member Functions

 Vector2 (T x=0.0, T y=0.0)
 Default constructor. More...
 
Vector2< T > operator- () const
 Compute the opposite vector. More...
 
Vector2< T > & operator+= (const Vector2< T > &other)
 Add a vector. More...
 
Vector2< T > & operator-= (const Vector2< T > &other)
 Substract a vector. More...
 
Vector2< T > & operator*= (T t)
 Multiply by a scalar. More...
 
Vector2< T > getOrthogonal () const
 Get the orthogonal vector. More...
 
getNorm () const
 Compute the euclidean norm of the vector. More...
 
getDistance (const Vector2< T > &other) const
 Compute the euclidean distance of this point to another point. More...
 
getDet (const Vector2< T > &other) const
 Compute the determinant with another vector. More...
 

Public Attributes

x
 
y
 

Related Functions

(Note that these are not member functions.)

template<typename T >
Vector2< T > operator+ (Vector2< T > lhs, const Vector2< T > &rhs)
 Compute the sum of two vectors. More...
 
template<typename T >
Vector2< T > operator- (Vector2< T > lhs, const Vector2< T > &rhs)
 Compute the difference of two vectors. More...
 
template<typename T >
Vector2< T > operator* (T t, Vector2< T > vec)
 Compute the product of a scalar by a vector. More...
 
template<typename T >
Vector2< T > operator* (Vector2< T > vec, T t)
 Compute the product of a vector by a scalar. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Vector2< T > &vec)
 Insert a vector in a stream. More...
 

Detailed Description

template<typename T>
class mygal::Vector2< T >

Class representing a 2D vector.

This class can be used to represent a 2D point too.

Author
Pierre Vigier

Definition at line 33 of file Vector2.h.

Constructor & Destructor Documentation

◆ Vector2()

template<typename T>
mygal::Vector2< T >::Vector2 ( x = 0.0,
y = 0.0 
)
inline

Default constructor.

Parameters
xx-coordinate
yy-coordinate

Definition at line 59 of file Vector2.h.

Member Function Documentation

◆ getDet()

template<typename T>
T mygal::Vector2< T >::getDet ( const Vector2< T > &  other) const
inline

Compute the determinant with another vector.

Parameters
otherOther vector to compute the determinant with
Returns
The determinant of this vector with other

Definition at line 162 of file Vector2.h.

◆ getDistance()

template<typename T>
T mygal::Vector2< T >::getDistance ( const Vector2< T > &  other) const
inline

Compute the euclidean distance of this point to another point.

In this function vectors are interpreted as points.

Parameters
otherOther point to compute the distance from
Returns
The euclidean distance of this point to other

Definition at line 150 of file Vector2.h.

◆ getNorm()

template<typename T>
T mygal::Vector2< T >::getNorm ( ) const
inline

Compute the euclidean norm of the vector.

Returns
The euclidean norm of the vector

Definition at line 136 of file Vector2.h.

◆ getOrthogonal()

template<typename T>
Vector2<T> mygal::Vector2< T >::getOrthogonal ( ) const
inline

Get the orthogonal vector.

Returns
The orthogonal vector

Definition at line 126 of file Vector2.h.

◆ operator*=()

template<typename T>
Vector2<T>& mygal::Vector2< T >::operator*= ( t)
inline

Multiply by a scalar.

Parameters
tScalar to multiply by
Returns
This vector after multiplication

Definition at line 112 of file Vector2.h.

◆ operator+=()

template<typename T>
Vector2<T>& mygal::Vector2< T >::operator+= ( const Vector2< T > &  other)
inline

Add a vector.

Parameters
otherVector to add
Returns
This vector after addition

Definition at line 84 of file Vector2.h.

◆ operator-()

template<typename T>
Vector2<T> mygal::Vector2< T >::operator- ( ) const
inline

Compute the opposite vector.

Returns
The opposite vector

Definition at line 72 of file Vector2.h.

◆ operator-=()

template<typename T>
Vector2<T>& mygal::Vector2< T >::operator-= ( const Vector2< T > &  other)
inline

Substract a vector.

Parameters
otherVector to substract
Returns
This vector after substraction

Definition at line 98 of file Vector2.h.

Friends And Related Function Documentation

◆ operator*() [1/2]

template<typename T >
Vector2< T > operator* ( t,
Vector2< T >  vec 
)
related

Compute the product of a scalar by a vector.

Parameters
tScalar
vecVector
Returns
Product of this scalar by this vector

Definition at line 212 of file Vector2.h.

◆ operator*() [2/2]

template<typename T >
Vector2< T > operator* ( Vector2< T >  vec,
t 
)
related

Compute the product of a vector by a scalar.

Parameters
vecVector
tScalar
Returns
Product of this vector by this scalar

Definition at line 228 of file Vector2.h.

◆ operator+()

template<typename T >
Vector2< T > operator+ ( Vector2< T >  lhs,
const Vector2< T > &  rhs 
)
related

Compute the sum of two vectors.

Parameters
lhsFirst vector
rhsSecond vector
Returns
Sum of these two vectors

Definition at line 180 of file Vector2.h.

◆ operator-()

template<typename T >
Vector2< T > operator- ( Vector2< T >  lhs,
const Vector2< T > &  rhs 
)
related

Compute the difference of two vectors.

Parameters
lhsFirst vector
rhsSecond vector
Returns
Difference of these two vectors

Definition at line 196 of file Vector2.h.

◆ operator<<()

template<typename T >
std::ostream & operator<< ( std::ostream &  os,
const Vector2< T > &  vec 
)
related

Insert a vector in a stream.

Parameters
osStream in which to insert the vector in
vecVector to insert in the stream
Returns
Stream after insertion

Definition at line 243 of file Vector2.h.

Member Data Documentation

◆ x

template<typename T>
T mygal::Vector2< T >::x

x-coordinate of the vector

Definition at line 50 of file Vector2.h.

◆ y

template<typename T>
T mygal::Vector2< T >::y

y-coordinate of the vector

Definition at line 51 of file Vector2.h.


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