JugiMap Framework
Vec2< T > Struct Template Reference

2d vector. More...

#include <jmCommon.h>

Public Member Functions

 Vec2 ()
 Constructs a vector with coordinates (0,0). More...
 
 Vec2 (T _x, T _y)
 Constructs a vector with the given coordinates **_x** and **_y**. More...
 
void Set (T _x, T _y)
 Sets the coordinates of this vector to the given **_x** and **_y**. More...
 
bool operator== (const Vec2< T > &v) const
 Returns true if this vector is equal to given vector v; otherwise returns false. More...
 
bool operator!= (const Vec2< T > &v) const
 Returns true if this vector is not equal to given vector v; otherwise returns false. More...
 
bool Equals (const Vec2< T > &v, float epsilon=0.00001f) const
 Returns true if the given vectors v is equal to this vector; otherwise returns false. For floating-point types: two compared numbers are considered equal if their difference is smaller then the given epsilon. More...
 
Vec2< Toperator- () const
 Return a vector object formed by changing the sign of this vector components. More...
 
Vec2< Toperator* (const Vec2< T > &v) const
 Returns a vector object formed by multiplying this vector with the given vector v. More...
 
Vec2< Toperator/ (const Vec2< T > &v) const
 Returns a vector object formed by dividing this vector with the given vector v. More...
 
Vec2< Toperator+ (const Vec2< T > &v) const
 Returns a vector object formed as the sum of the given s to this vector. More...
 
Vec2< Toperator- (const Vec2< T > &v) const
 Returns a vector object formed by subtracting the given v from this vector. More...
 
Vec2< T > & operator+= (const Vec2< T > &v)
 Adds the given vector v to this vector and return a reference to this vector. More...
 
Vec2< T > & operator-= (const Vec2< T > &v)
 Subtracts the given vector v from this vector and return a reference to this vector. More...
 
Vec2< T > & operator*= (const Vec2< T > &v)
 Multiplyes this vector with the given vector v and return a reference to this vector. More...
 
Vec2< T > & operator/= (const Vec2< T > &v)
 Divides this vector with the given vector v and return a reference to this vector. More...
 
Vec2< T > & operator+= (T s)
 Adds the given s to this vector and return a reference to this vector. More...
 
Vec2< T > & operator-= (T s)
 Subtracts the given s from this vector and return a reference to this vector. More...
 
Vec2< T > & operator*= (T s)
 Multiplies this vector with the given s and return a reference to this vector. More...
 
Vec2< T > & operator/= (T s)
 Divides this vector with the given s and return a reference to this vector. More...
 
Vec2< Toperator* (double s) const
 Returns a vector object formed by multiplying this vector with the given s. More...
 
Vec2< Toperator/ (double s) const
 Returns a vector object formed by dividing this vector with the given s. More...
 
Vec2< Toperator+ (T s) const
 Returns a vector object formed by adding the given s to this vector. More...
 
Vec2< Toperator- (T s) const
 Returns a vector object formed by subtracting the given s from this vector. More...
 
double GetLength () const
 Returns the length of this vector. More...
 
double GetLength2 () const
 Returns the square length of this vector. More...
 
double Distance (const Vec2< T > &v) const
 Return the distance from the given vector v. More...
 
double Distance2 (const Vec2< T > &v) const
 Returns the square distance from the given vector v. More...
 
Vec2< TNormalize () const
 Returns a vector object formed by normalizing this vector. More...
 
T Dot (const Vec2< T > &v) const
 Returns the dot product of this vector and the given vector v. More...
 

Public Attributes

T x
 The x coordinate. More...
 
T y
 The y coordinate. More...
 

Detailed Description

template<typename T>
struct jugimap::Vec2< T >

2d vector.

Constructor & Destructor Documentation

◆ Vec2() [1/2]

Vec2 ( )
inline

Constructs a vector with coordinates (0,0).

◆ Vec2() [2/2]

Vec2 ( T  _x,
T  _y 
)
inline

Constructs a vector with the given coordinates **_x** and **_y**.

Member Function Documentation

◆ Set()

void Set ( T  _x,
T  _y 
)
inline

Sets the coordinates of this vector to the given **_x** and **_y**.

◆ operator==()

bool operator== ( const Vec2< T > &  v) const
inline

Returns true if this vector is equal to given vector v; otherwise returns false.

◆ operator!=()

bool operator!= ( const Vec2< T > &  v) const
inline

Returns true if this vector is not equal to given vector v; otherwise returns false.

◆ Equals()

bool Equals ( const Vec2< T > &  v,
float  epsilon = 0.00001f 
) const
inline

Returns true if the given vectors v is equal to this vector; otherwise returns false. For floating-point types: two compared numbers are considered equal if their difference is smaller then the given epsilon.

◆ operator-() [1/3]

Vec2<T> operator- ( ) const
inline

Return a vector object formed by changing the sign of this vector components.

◆ operator*() [1/2]

Vec2<T> operator* ( const Vec2< T > &  v) const
inline

Returns a vector object formed by multiplying this vector with the given vector v.

◆ operator/() [1/2]

Vec2<T> operator/ ( const Vec2< T > &  v) const
inline

Returns a vector object formed by dividing this vector with the given vector v.

◆ operator+() [1/2]

Vec2<T> operator+ ( const Vec2< T > &  v) const
inline

Returns a vector object formed as the sum of the given s to this vector.

◆ operator-() [2/3]

Vec2<T> operator- ( const Vec2< T > &  v) const
inline

Returns a vector object formed by subtracting the given v from this vector.

◆ operator+=() [1/2]

Vec2<T>& operator+= ( const Vec2< T > &  v)
inline

Adds the given vector v to this vector and return a reference to this vector.

◆ operator-=() [1/2]

Vec2<T>& operator-= ( const Vec2< T > &  v)
inline

Subtracts the given vector v from this vector and return a reference to this vector.

◆ operator*=() [1/2]

Vec2<T>& operator*= ( const Vec2< T > &  v)
inline

Multiplyes this vector with the given vector v and return a reference to this vector.

◆ operator/=() [1/2]

Vec2<T>& operator/= ( const Vec2< T > &  v)
inline

Divides this vector with the given vector v and return a reference to this vector.

◆ operator+=() [2/2]

Vec2<T>& operator+= ( T  s)
inline

Adds the given s to this vector and return a reference to this vector.

◆ operator-=() [2/2]

Vec2<T>& operator-= ( T  s)
inline

Subtracts the given s from this vector and return a reference to this vector.

◆ operator*=() [2/2]

Vec2<T>& operator*= ( T  s)
inline

Multiplies this vector with the given s and return a reference to this vector.

◆ operator/=() [2/2]

Vec2<T>& operator/= ( T  s)
inline

Divides this vector with the given s and return a reference to this vector.

◆ operator*() [2/2]

Vec2<T> operator* ( double  s) const
inline

Returns a vector object formed by multiplying this vector with the given s.

◆ operator/() [2/2]

Vec2<T> operator/ ( double  s) const
inline

Returns a vector object formed by dividing this vector with the given s.

◆ operator+() [2/2]

Vec2<T> operator+ ( T  s) const
inline

Returns a vector object formed by adding the given s to this vector.

◆ operator-() [3/3]

Vec2<T> operator- ( T  s) const
inline

Returns a vector object formed by subtracting the given s from this vector.

◆ GetLength()

double GetLength ( ) const
inline

Returns the length of this vector.

◆ GetLength2()

double GetLength2 ( ) const
inline

Returns the square length of this vector.

◆ Distance()

double Distance ( const Vec2< T > &  v) const
inline

Return the distance from the given vector v.

◆ Distance2()

double Distance2 ( const Vec2< T > &  v) const
inline

Returns the square distance from the given vector v.

◆ Normalize()

Vec2<T> Normalize ( ) const
inline

Returns a vector object formed by normalizing this vector.

◆ Dot()

T Dot ( const Vec2< T > &  v) const
inline

Returns the dot product of this vector and the given vector v.

Member Data Documentation

◆ x

T x

The x coordinate.

◆ y

T y

The y coordinate.


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