claw::math::vector_2d< T > Class Template Reference

Two dimensional vector. More...

#include <vector_2d.hpp>

Inheritance diagram for claw::math::vector_2d< T >:
claw::math::coordinate_2d< T >

List of all members.

Public Types

typedef T value_type
 The type of the values we store.
typedef vector_2d< value_typeself_type
 The type of the current class.
typedef coordinate_2d< value_typesuper
 The type of the parent class.

Public Member Functions

 vector_2d ()
 Constructor.
template<class U >
 vector_2d (const coordinate_2d< U > &that)
 Copy constructor.
template<class U >
 vector_2d (const coordinate_2d< U > &p1, const coordinate_2d< U > &p2)
 Construct a vector from two points.
 vector_2d (const value_type &_x, const value_type &_y)
 Constructor with initialization.
value_type length () const
 Gets vector length.
void normalize ()
 Normalize the vector.
self_type get_orthonormal_clockwise () const
 Get a vector orthonormal to this vector.
self_type get_orthonormal_anticlockwise () const
 Get a vector orthonormal to this vector.
value_type dot_product (const self_type &vect) const
 Dot product.

Detailed Description

template<class T>
class claw::math::vector_2d< T >

Two dimensional vector.

Author:
Julien Jorge

Definition at line 44 of file vector_2d.hpp.


Member Typedef Documentation

template<class T>
typedef vector_2d<value_type> claw::math::vector_2d< T >::self_type

The type of the current class.

Reimplemented from claw::math::coordinate_2d< T >.

Definition at line 52 of file vector_2d.hpp.

template<class T>
typedef coordinate_2d<value_type> claw::math::vector_2d< T >::super

The type of the parent class.

Definition at line 55 of file vector_2d.hpp.

template<class T>
typedef T claw::math::vector_2d< T >::value_type

The type of the values we store.

Reimplemented from claw::math::coordinate_2d< T >.

Definition at line 49 of file vector_2d.hpp.


Constructor & Destructor Documentation

template<class T >
claw::math::vector_2d< T >::vector_2d (  )  [inline]

Constructor.

Definition at line 37 of file vector_2d.tpp.

00038 {
00039 
00040 } // vector_2d::vector_2d() [constructor]

template<class T >
template<class U >
claw::math::vector_2d< T >::vector_2d ( const coordinate_2d< U > &  that  )  [inline]

Copy constructor.

Definition at line 48 of file vector_2d.tpp.

00049   : super(that)
00050 {
00051 
00052 } // vector_2d::vector_2d() [copy constructor]

template<class T >
template<class U >
claw::math::vector_2d< T >::vector_2d ( const coordinate_2d< U > &  p1,
const coordinate_2d< U > &  p2 
) [inline]

Construct a vector from two points.

Definition at line 61 of file vector_2d.tpp.

00062   : super( p2.x - p1.x, p2.y - p1.y )
00063 {
00064 
00065 } // vector_2d::vector_2d() [constructor from two points]

template<class T >
claw::math::vector_2d< T >::vector_2d ( const value_type _x,
const value_type _y 
) [inline]

Constructor with initialization.

Parameters:
_x x value.
_y y Value.

Definition at line 74 of file vector_2d.tpp.

00075   : super(_x, _y)
00076 {
00077 
00078 } // vector_2d::vector_2d() [constructor whit values]


Member Function Documentation

template<class T >
claw::math::vector_2d< T >::value_type claw::math::vector_2d< T >::dot_product ( const self_type that  )  const [inline]

Dot product.

Parameters:
that The other operand.

Definition at line 136 of file vector_2d.tpp.

References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

Referenced by claw::math::line_2d< T >::orthogonal().

00137 {       
00138   return this->x * that.x + this->y * that.y;
00139 } // vector_2d::dot_product()

template<class T >
claw::math::vector_2d< T > claw::math::vector_2d< T >::get_orthonormal_anticlockwise (  )  const [inline]

Get a vector orthonormal to this vector.

Definition at line 124 of file vector_2d.tpp.

References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

00125 {
00126   return self_type(-this->y, this->x);
00127 } // vector_2d::get_orthonormal_anticlockwise()

template<class T >
claw::math::vector_2d< T > claw::math::vector_2d< T >::get_orthonormal_clockwise (  )  const [inline]

Get a vector orthonormal to this vector.

Definition at line 113 of file vector_2d.tpp.

References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

00114 {
00115   return self_type(this->y, -this->x);
00116 } // vector_2d::get_orthonormal_clockwise()

template<class T >
claw::math::vector_2d< T >::value_type claw::math::vector_2d< T >::length (  )  const [inline]

Gets vector length.

Definition at line 86 of file vector_2d.tpp.

References claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

Referenced by claw::math::vector_2d< T >::normalize().

00087 {
00088   return std::sqrt( (this->x * this->x) + (this->y * this->y) ); 
00089 } // vector_2d::length()

template<class T >
void claw::math::vector_2d< T >::normalize (  )  [inline]

Normalize the vector.

Definition at line 96 of file vector_2d.tpp.

References claw::math::vector_2d< T >::length(), claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.

00097 {
00098   value_type l = length();
00099   
00100   if (l != 0)
00101     {
00102       this->x /= l;
00103       this->y /= l;
00104     }
00105 } // vector_2d::normalize()


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

Generated on 9 Nov 2009 for CLAW Library (a C++ Library Absolutely Wonderful) by  doxygen 1.6.1