Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

irr::core::vector2d< T > Class Template Reference

2d vector template class with lots of operators and methods. More...

#include <vector2d.h>

List of all members.

Public Member Functions

dotProduct (const vector2d< T > &other) const
 Get the dot product of this vector with another.
bool equals (const vector2d< T > &other) const
 Checks if this vector equals the other one.
f64 getAngle () const
 Calculates the angle of this vector in degrees in the counter trigonometric sense.
f64 getAngleTrig () const
 Calculates the angle of this vector in degrees in the trigonometric sense.
f64 getAngleWith (const vector2d< T > &b) const
 Calculates the angle between this vector and another one in degree.
getDistanceFrom (const vector2d< T > &other) const
 Gets distance from another point.
getDistanceFromSQ (const vector2d< T > &other) const
 Returns squared distance from another point.
vector2d< T > getInterpolated (const vector2d< T > &other, f64 d) const
 Creates an interpolated vector between this vector and another vector.
vector2d< T > getInterpolated_quadratic (const vector2d< T > &v2, const vector2d< T > &v3, f64 d) const
 Creates a quadratically interpolated vector between this and two other vectors.
getLength () const
 Gets the length of the vector.
getLengthSQ () const
 Get the squared length of this vector.
vector2d< T > & interpolate (const vector2d< T > &a, const vector2d< T > &b, f64 d)
 Sets this vector to the linearly interpolated vector between a and b.
bool isBetweenPoints (const vector2d< T > &begin, const vector2d< T > &end) const
 Returns if this vector interpreted as a point is on a line between two other points.
vector2d< T > & normalize ()
 Normalize the vector.
bool operator!= (const vector2d< T > &other) const
vector2d< T > operator* (const T v) const
vector2d< T > operator* (const vector2d< T > &other) const
vector2d< T > & operator*= (const T v)
vector2d< T > & operator*= (const vector2d< T > &other)
vector2d< T > operator+ (const T v) const
vector2d< T > operator+ (const dimension2d< T > &other) const
vector2d< T > operator+ (const vector2d< T > &other) const
vector2d< T > & operator+= (const dimension2d< T > &other)
vector2d< T > & operator+= (const T v)
vector2d< T > & operator+= (const vector2d< T > &other)
vector2d< T > operator- (const T v) const
vector2d< T > operator- (const dimension2d< T > &other) const
vector2d< T > operator- (const vector2d< T > &other) const
vector2d< T > operator- () const
vector2d< T > & operator-= (const dimension2d< T > &other)
vector2d< T > & operator-= (const T v)
vector2d< T > & operator-= (const vector2d< T > &other)
vector2d< T > operator/ (const T v) const
vector2d< T > operator/ (const vector2d< T > &other) const
vector2d< T > & operator/= (const T v)
vector2d< T > & operator/= (const vector2d< T > &other)
bool operator< (const vector2d< T > &other) const
bool operator<= (const vector2d< T > &other) const
vector2d< T > & operator= (const dimension2d< T > &other)
vector2d< T > & operator= (const vector2d< T > &other)
bool operator== (const vector2d< T > &other) const
bool operator> (const vector2d< T > &other) const
bool operator>= (const vector2d< T > &other) const
vector2d< T > & rotateBy (f64 degrees, const vector2d< T > &center=vector2d< T >())
 rotates the point anticlockwise around a center by an amount of degrees.
vector2d< T > & set (const vector2d< T > &p)
vector2d< T > & set (T nx, T ny)
 vector2d (const dimension2d< T > &other)
 vector2d (const vector2d< T > &other)
 Copy constructor.
 vector2d (T n)
 Constructor with the same value for both members.
 vector2d (T nx, T ny)
 Constructor with two different values.
 vector2d ()
 Default constructor (null vector).

Public Attributes

X
 X coordinate of vector.
Y
 Y coordinate of vector.


Detailed Description

template<class T>
class irr::core::vector2d< T >

2d vector template class with lots of operators and methods.

As of Irrlicht 1.6, this class supercedes position2d, which should be considered deprecated.

Definition at line 21 of file vector2d.h.


Constructor & Destructor Documentation

template<class T>
irr::core::vector2d< T >::vector2d (  )  [inline]

Default constructor (null vector).

Definition at line 25 of file vector2d.h.

template<class T>
irr::core::vector2d< T >::vector2d ( nx,
ny 
) [inline]

Constructor with two different values.

Definition at line 27 of file vector2d.h.

template<class T>
irr::core::vector2d< T >::vector2d ( n  )  [inline, explicit]

Constructor with the same value for both members.

Definition at line 29 of file vector2d.h.

template<class T>
irr::core::vector2d< T >::vector2d ( const vector2d< T > &  other  )  [inline]

Copy constructor.

Definition at line 31 of file vector2d.h.

template<class T>
irr::core::vector2d< T >::vector2d ( const dimension2d< T > &  other  )  [inline]

Definition at line 33 of file vector2d.h.


Member Function Documentation

template<class T>
T irr::core::vector2d< T >::dotProduct ( const vector2d< T > &  other  )  const [inline]

Get the dot product of this vector with another.

Parameters:
other Other vector to take dot product with.
Returns:
The dot product of the two vectors.

Definition at line 102 of file vector2d.h.

Referenced by irr::core::line2d< T >::getClosestPoint().

template<class T>
bool irr::core::vector2d< T >::equals ( const vector2d< T > &  other  )  const [inline]

Checks if this vector equals the other one.

Takes floating point rounding errors into account.

Parameters:
other Vector to compare with.
Returns:
True if the two vector are (almost) equal, else false.

Definition at line 82 of file vector2d.h.

Referenced by irr::core::vector2d< float >::operator!=(), and irr::core::vector2d< float >::operator==().

template<class T>
f64 irr::core::vector2d< T >::getAngle (  )  const [inline]

Calculates the angle of this vector in degrees in the counter trigonometric sense.

0 is to the right (3 o'clock), values increase clockwise.

Returns:
Returns a value between 0 and 360.

Definition at line 186 of file vector2d.h.

template<class T>
f64 irr::core::vector2d< T >::getAngleTrig (  )  const [inline]

Calculates the angle of this vector in degrees in the trigonometric sense.

0 is to the right (3 o'clock), values increase counter-clockwise. This method has been suggested by Pr3t3nd3r.

Returns:
Returns a value between 0 and 360.

Definition at line 163 of file vector2d.h.

template<class T>
f64 irr::core::vector2d< T >::getAngleWith ( const vector2d< T > &  b  )  const [inline]

Calculates the angle between this vector and another one in degree.

Parameters:
b Other vector to test with.
Returns:
Returns a value between 0 and 90.

Definition at line 215 of file vector2d.h.

Referenced by irr::core::line2d< T >::getAngleWith().

template<class T>
T irr::core::vector2d< T >::getDistanceFrom ( const vector2d< T > &  other  )  const [inline]

Gets distance from another point.

Here, the vector is interpreted as a point in 2-dimensional space.

Parameters:
other Other vector to measure from.
Returns:
Distance from other point.

Definition at line 111 of file vector2d.h.

template<class T>
T irr::core::vector2d< T >::getDistanceFromSQ ( const vector2d< T > &  other  )  const [inline]

Returns squared distance from another point.

Here, the vector is interpreted as a point in 2-dimensional space.

Parameters:
other Other vector to measure from.
Returns:
Squared distance from other point.

Definition at line 120 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::getInterpolated ( const vector2d< T > &  other,
f64  d 
) const [inline]

Creates an interpolated vector between this vector and another vector.

Parameters:
other The other vector to interpolate with.
d Interpolation value between 0.0f (all the other vector) and 1.0f (all this vector). Note that this is the opposite direction of interpolation to getInterpolated_quadratic()
Returns:
An interpolated vector. This vector is not modified.

Definition at line 253 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::getInterpolated_quadratic ( const vector2d< T > &  v2,
const vector2d< T > &  v3,
f64  d 
) const [inline]

Creates a quadratically interpolated vector between this and two other vectors.

Parameters:
v2 Second vector to interpolate with.
v3 Third vector to interpolate with (maximum at 1.0f)
d Interpolation value between 0.0f (all this vector) and 1.0f (all the 3rd vector). Note that this is the opposite direction of interpolation to getInterpolated() and interpolate()
Returns:
An interpolated vector. This vector is not modified.

Definition at line 265 of file vector2d.h.

template<class T>
T irr::core::vector2d< T >::getLength (  )  const [inline]

Gets the length of the vector.

Returns:
The length of the vector.

Definition at line 92 of file vector2d.h.

Referenced by irr::core::line2d< T >::getClosestPoint(), and irr::core::vector2d< float >::getDistanceFrom().

template<class T>
T irr::core::vector2d< T >::getLengthSQ (  )  const [inline]

Get the squared length of this vector.

This is useful because it is much faster than getLength().

Returns:
The squared length of the vector.

Definition at line 97 of file vector2d.h.

Referenced by irr::core::vector2d< float >::getDistanceFromSQ().

template<class T>
vector2d<T>& irr::core::vector2d< T >::interpolate ( const vector2d< T > &  a,
const vector2d< T > &  b,
f64  d 
) [inline]

Sets this vector to the linearly interpolated vector between a and b.

Parameters:
a first vector to interpolate with, maximum at 1.0f
b second vector to interpolate with, maximum at 0.0f
d Interpolation value between 0.0f (all vector b) and 1.0f (all vector a) Note that this is the opposite direction of interpolation to getInterpolated_quadratic()

Definition at line 283 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::isBetweenPoints ( const vector2d< T > &  begin,
const vector2d< T > &  end 
) const [inline]

Returns if this vector interpreted as a point is on a line between two other points.

It is assumed that the point is on the line.

Parameters:
begin Beginning vector to compare between.
end Ending vector to compare between.
Returns:
True if this vector is between begin and end, false if not.

Definition at line 234 of file vector2d.h.

Referenced by irr::core::line2d< T >::isPointBetweenStartAndEnd(), and irr::core::line2d< T >::isPointOnLine().

template<class T>
vector2d<T>& irr::core::vector2d< T >::normalize (  )  [inline]

Normalize the vector.

The null vector is left untouched.

Returns:
Reference to this vector, after normalization.

Definition at line 148 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::operator!= ( const vector2d< T > &  other  )  const [inline]

Definition at line 74 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator* ( const T  v  )  const [inline]

Definition at line 59 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator* ( const vector2d< T > &  other  )  const [inline]

Definition at line 57 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator*= ( const T  v  )  [inline]

Definition at line 60 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator*= ( const vector2d< T > &  other  )  [inline]

Definition at line 58 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator+ ( const T  v  )  const [inline]

Definition at line 46 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator+ ( const dimension2d< T > &  other  )  const [inline]

Definition at line 44 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator+ ( const vector2d< T > &  other  )  const [inline]

Definition at line 43 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator+= ( const dimension2d< T > &  other  )  [inline]

Definition at line 48 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator+= ( const T  v  )  [inline]

Definition at line 47 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator+= ( const vector2d< T > &  other  )  [inline]

Definition at line 45 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator- ( const T  v  )  const [inline]

Definition at line 53 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator- ( const dimension2d< T > &  other  )  const [inline]

Definition at line 51 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator- ( const vector2d< T > &  other  )  const [inline]

Definition at line 50 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator- (  )  const [inline]

Definition at line 37 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator-= ( const dimension2d< T > &  other  )  [inline]

Definition at line 55 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator-= ( const T  v  )  [inline]

Definition at line 54 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator-= ( const vector2d< T > &  other  )  [inline]

Definition at line 52 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator/ ( const T  v  )  const [inline]

Definition at line 64 of file vector2d.h.

template<class T>
vector2d<T> irr::core::vector2d< T >::operator/ ( const vector2d< T > &  other  )  const [inline]

Definition at line 62 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator/= ( const T  v  )  [inline]

Definition at line 65 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator/= ( const vector2d< T > &  other  )  [inline]

Definition at line 63 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::operator< ( const vector2d< T > &  other  )  const [inline]

Definition at line 70 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::operator<= ( const vector2d< T > &  other  )  const [inline]

Definition at line 67 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator= ( const dimension2d< T > &  other  )  [inline]

Definition at line 41 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::operator= ( const vector2d< T > &  other  )  [inline]

Definition at line 39 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::operator== ( const vector2d< T > &  other  )  const [inline]

Definition at line 73 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::operator> ( const vector2d< T > &  other  )  const [inline]

Definition at line 71 of file vector2d.h.

template<class T>
bool irr::core::vector2d< T >::operator>= ( const vector2d< T > &  other  )  const [inline]

Definition at line 68 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::rotateBy ( f64  degrees,
const vector2d< T > &  center = vector2d<T>() 
) [inline]

rotates the point anticlockwise around a center by an amount of degrees.

Parameters:
degrees Amount of degrees to rotate by, anticlockwise.
center Rotation center.
Returns:
This vector after transformation.

Definition at line 129 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::set ( const vector2d< T > &  p  )  [inline]

Definition at line 88 of file vector2d.h.

template<class T>
vector2d<T>& irr::core::vector2d< T >::set ( nx,
ny 
) [inline]

Definition at line 87 of file vector2d.h.


Member Data Documentation

template<class T>
T irr::core::vector2d< T >::X

X coordinate of vector.

Definition at line 291 of file vector2d.h.

Referenced by irr::core::CMatrix4< T >::buildTextureTransform(), irr::gui::IGUIElement::deserializeAttributes(), irr::core::vector2d< float >::dotProduct(), irr::core::vector2d< float >::equals(), irr::core::vector2d< float >::getAngle(), irr::core::vector2d< float >::getAngleTrig(), irr::core::vector2d< float >::getAngleWith(), irr::core::vector2d< float >::getDistanceFrom(), irr::core::vector2d< float >::getDistanceFromSQ(), irr::core::vector2d< float >::getInterpolated(), irr::core::vector2d< float >::getInterpolated_quadratic(), irr::core::vector2d< float >::getLength(), irr::core::vector2d< float >::getLengthSQ(), irr::core::line2d< T >::getPointOrientation(), irr::core::vector2d< float >::interpolate(), irr::core::line2d< T >::intersectWith(), irr::core::vector2d< float >::isBetweenPoints(), irr::core::vector2d< float >::normalize(), irr::core::vector2d< float >::operator*(), irr::core::vector2d< float >::operator*=(), irr::core::vector2d< float >::operator+(), irr::core::vector2d< float >::operator+=(), irr::core::vector2d< float >::operator-(), irr::core::vector2d< float >::operator-=(), irr::core::vector2d< float >::operator/(), irr::core::vector2d< float >::operator/=(), irr::core::vector2d< float >::operator<(), irr::core::vector2d< float >::operator<=(), irr::core::vector2d< float >::operator=(), irr::core::dimension2d< T >::operator==(), irr::core::vector2d< float >::operator>(), irr::core::vector2d< float >::operator>=(), irr::core::vector2d< float >::rotateBy(), irr::core::vector2d< float >::set(), and irr::gui::IGUIElement::setRelativePosition().

template<class T>
T irr::core::vector2d< T >::Y

Y coordinate of vector.

Definition at line 294 of file vector2d.h.

Referenced by irr::core::CMatrix4< T >::buildTextureTransform(), irr::gui::IGUIElement::deserializeAttributes(), irr::core::vector2d< float >::dotProduct(), irr::core::vector2d< float >::equals(), irr::core::vector2d< float >::getAngle(), irr::core::vector2d< float >::getAngleTrig(), irr::core::vector2d< float >::getAngleWith(), irr::core::vector2d< float >::getDistanceFrom(), irr::core::vector2d< float >::getDistanceFromSQ(), irr::core::vector2d< float >::getInterpolated(), irr::core::vector2d< float >::getInterpolated_quadratic(), irr::core::vector2d< float >::getLength(), irr::core::vector2d< float >::getLengthSQ(), irr::core::line2d< T >::getPointOrientation(), irr::core::vector2d< float >::interpolate(), irr::core::line2d< T >::intersectWith(), irr::core::vector2d< float >::isBetweenPoints(), irr::core::vector2d< float >::normalize(), irr::core::vector2d< float >::operator*(), irr::core::vector2d< float >::operator*=(), irr::core::vector2d< float >::operator+(), irr::core::vector2d< float >::operator+=(), irr::core::vector2d< float >::operator-(), irr::core::vector2d< float >::operator-=(), irr::core::vector2d< float >::operator/(), irr::core::vector2d< float >::operator/=(), irr::core::vector2d< float >::operator<(), irr::core::vector2d< float >::operator<=(), irr::core::vector2d< float >::operator=(), irr::core::dimension2d< T >::operator==(), irr::core::vector2d< float >::operator>(), irr::core::vector2d< float >::operator>=(), irr::core::vector2d< float >::rotateBy(), irr::core::vector2d< float >::set(), and irr::gui::IGUIElement::setRelativePosition().


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

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:10 2010 by Doxygen (1.5.6)