mathglpp::GLIVector2< T > Class Template Reference

#include <GLVector.h>

Collaboration diagram for mathglpp::GLIVector2< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename T>
class mathglpp::GLIVector2< T >

a 2D vector class for OpenGL

Definition at line 252 of file GLVector.h.

Public Types

enum  { D = 2 }

Public Member Functions

 GLIVector2 (const GLIVector2 &gv)
 Address another vector.
 GLIVector2 (T *f)
 Wrap a vector from an array.
 ~GLIVector2 ()
 Default destructor.
void set (const T &v1, const T &v2)
 element by element initialiser
T & operator[] (int ind)
 element by element accessor
 operator T * (void)
 implicit casting to a pointer
 operator const T * (void) const
 implicit casting to a const pointer
void glScale () const
 GL interface, glScale().
void glRotate (const T &ang) const
 GL interface, glRotate().
void glTranslate () const
 GL interface, glTranslate().
void glVertex () const
 GL interface, glVertex().
void glNormal () const
 GL interface, glNormal().
const GLVector2< T > operator+ (const GLVector2< T > &gv) const
 Get the sum of this and a vector.
const GLVector2< T > operator+ (const GLIVector2 &gv) const
 Get the sum of this and a vector.
const GLVector2< T > operator- (const GLVector2< T > &gv) const
 Get the difference of this and a vector.
const GLVector2< T > operator- (const GLIVector2 &gv) const
 Get the difference of this and a vector.
const GLVector2< T > operator * (const GLVector2< T > &gv) const
 Get the element-by-element product of this and a vector.
const GLVector2< T > operator * (const GLIVector2 &gv) const
 Get the element-by-element product of this and a vector.
const GLVector2< T > operator/ (const GLVector2< T > &gv) const
 Get the element-by-element quota of this and a vector.
const GLVector2< T > operator/ (const GLIVector2 &gv) const
 Get the element-by-element quota of this and a vector.
const GLVector2< T > operator * (const T &v) const
 Get the element-by-element product of this and a scalar.
const GLVector2< T > operator/ (const T &v) const
 Get the element-by-element quota of this and a scalar.
GLIVector2operator+= (const GLVector2< T > &gv)
 Add a vector to this.
GLIVector2operator+= (const GLIVector2 &gv)
 Add a vector to this.
GLIVector2operator-= (const GLVector2< T > &gv)
 Subtract a vector from this.
GLIVector2operator-= (const GLIVector2< T > &gv)
 Subtract a vector from this.
GLIVector2operator *= (const T &f)
 Multiply this by a scalar.
GLIVector2operator/= (const T &f)
 Divide this by a scalar.
GLIVector2operator= (const GLVector2< T > &v)
 copy this from a vector
GLIVector2operator= (const GLIVector2 &v)
 copy this from a vector
const GLVector2< T > operator- () const
 negate this
const T dot (const GLVector2< T > &gv) const
 Get the dot product of this and a vector.
const T dot (const GLIVector2 &gv) const
 Get the dot product of this and a vector.
length () const
 Get the length of this.
lengthSqr () const
 Get the length squared, less computation than length().
const GLVector2< T > unit () const
 Get the the unit vector of this.
GLIVector2normalize ()
 Normalize this, makes this a unit vector, US spelling.
const T projection (const GLVector2< T > &in) const
 Get the projection of this and a vector.
const T projection (const GLIVector2 &in) const
 Get the projection of this and a vector.
GLVector2< T > orthogonalProjection (const GLVector2< T > &in) const
 Get the orthogonal projection of this and a vector.
GLVector2< T > orthogonalProjection (const GLIVector2 &in) const
 Get the orthogonal projection of this and a vector.
GLVector2< T > vectorProjection (const GLVector2< T > &in) const
 Get the vector projection of this and a vector.
GLVector2< T > vectorProjection (const GLIVector2 &in) const
 Get the vector projection of this and a vector.

Public Attributes

T * val


Member Enumeration Documentation

template<typename T>
anonymous enum

Enumerator:
D 

Definition at line 255 of file GLVector.h.

00255 { D = 2 };


Constructor & Destructor Documentation

template<typename T>
mathglpp::GLIVector2< T >::GLIVector2 ( const GLIVector2< T > &  gv  )  [inline]

Address another vector.

Definition at line 258 of file GLVector.h.

00259     :val(gv.val)
00260     { }

template<typename T>
mathglpp::GLIVector2< T >::GLIVector2 ( T *  f  )  [inline]

Wrap a vector from an array.

Definition at line 263 of file GLVector.h.

00264     :val(f)
00265     { }

template<typename T>
mathglpp::GLIVector2< T >::~GLIVector2 (  )  [inline]

Default destructor.

Definition at line 268 of file GLVector.h.

00268 {}


Member Function Documentation

template<typename T>
void mathglpp::GLIVector2< T >::set ( const T &  v1,
const T &  v2 
) [inline]

element by element initialiser

Definition at line 271 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00272     {   val[0] = v1; val[1] = v2; }

template<typename T>
T& mathglpp::GLIVector2< T >::operator[] ( int  ind  )  [inline]

element by element accessor

Definition at line 275 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00276     {   return val[ind]; }

template<typename T>
mathglpp::GLIVector2< T >::operator T * ( void   )  [inline]

implicit casting to a pointer

Definition at line 279 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00280     {   return val; }

template<typename T>
mathglpp::GLIVector2< T >::operator const T * ( void   )  const [inline]

implicit casting to a const pointer

Definition at line 283 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00284     {   return val; }

template<typename T>
void mathglpp::GLIVector2< T >::glScale (  )  const [inline]

GL interface, glScale().

template<typename T>
void mathglpp::GLIVector2< T >::glRotate ( const T &  ang  )  const [inline]

GL interface, glRotate().

template<typename T>
void mathglpp::GLIVector2< T >::glTranslate (  )  const [inline]

GL interface, glTranslate().

template<typename T>
void mathglpp::GLIVector2< T >::glVertex (  )  const [inline]

GL interface, glVertex().

Definition at line 293 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00293 { mathglpp::glVertexv<D,T>(val); }

template<typename T>
void mathglpp::GLIVector2< T >::glNormal (  )  const [inline]

GL interface, glNormal().

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator+ ( const GLVector2< T > &  gv  )  const [inline]

Get the sum of this and a vector.

Definition at line 298 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

00299     {
00300         return GLVector2<T>(val[0]+gv.x,val[1]+gv.y);
00301     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator+ ( const GLIVector2< T > &  gv  )  const [inline]

Get the sum of this and a vector.

Definition at line 304 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00305     {
00306         return GLVector2<T>(val[0]+gv.val[0],val[1]+gv.val[1]);
00307     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator- ( const GLVector2< T > &  gv  )  const [inline]

Get the difference of this and a vector.

Definition at line 310 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

00311     {
00312         return GLVector2<T>(val[0]-gv.x,val[1]-gv.y);
00313     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator- ( const GLIVector2< T > &  gv  )  const [inline]

Get the difference of this and a vector.

Definition at line 316 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00317     {
00318         return GLVector2<T>(val[0]-gv.val[0],val[1]-gv.val[1]);
00319     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator * ( const GLVector2< T > &  gv  )  const [inline]

Get the element-by-element product of this and a vector.

Definition at line 322 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

00323     {
00324         return GLVector2<T>(val[0]*gv.x,val[1]*gv.y);
00325     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator * ( const GLIVector2< T > &  gv  )  const [inline]

Get the element-by-element product of this and a vector.

Definition at line 328 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00329     {
00330         return GLVector2<T>(val[0]*gv.x,val[1]*gv.y);
00331     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator/ ( const GLVector2< T > &  gv  )  const [inline]

Get the element-by-element quota of this and a vector.

Definition at line 334 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

00335     {
00336         return GLVector2<T>(val[0]/gv.x,val[1]/gv.y);
00337     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator/ ( const GLIVector2< T > &  gv  )  const [inline]

Get the element-by-element quota of this and a vector.

Definition at line 340 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00341     {
00342         return GLVector2<T>(val[0]/gv.val[0],val[1]/gv.val[1]);
00343     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator * ( const T &  v  )  const [inline]

Get the element-by-element product of this and a scalar.

Definition at line 346 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00347     {
00348         return GLVector2<T>(val[0]*v,val[1]*v);
00349     }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator/ ( const T &  v  )  const [inline]

Get the element-by-element quota of this and a scalar.

Definition at line 352 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00353     {
00354         return GLVector2<T>(val[0]/v,val[1]/v);
00355     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator+= ( const GLVector2< T > &  gv  )  [inline]

Add a vector to this.

Definition at line 358 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

00359     {
00360         val[0] += gv.x;
00361         val[1] += gv.y;
00362         return *this;
00363     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator+= ( const GLIVector2< T > &  gv  )  [inline]

Add a vector to this.

Definition at line 366 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00367     {
00368         val[0] += gv.val[0];
00369         val[1] += gv.val[0];
00370         return *this;
00371     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator-= ( const GLVector2< T > &  gv  )  [inline]

Subtract a vector from this.

Definition at line 374 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

00375     {
00376         val[0] -= gv.x;
00377         val[1] -= gv.y;
00378         return *this;
00379     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator-= ( const GLIVector2< T > &  gv  )  [inline]

Subtract a vector from this.

Definition at line 382 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00383     {
00384         val[0] -= gv.val[0];
00385         val[1] -= gv.val[1];
00386         return *this;
00387     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator *= ( const T &  f  )  [inline]

Multiply this by a scalar.

Definition at line 390 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00391     {
00392         val[0] *= f;
00393         val[1] *= f;
00394         return *this;
00395     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator/= ( const T &  f  )  [inline]

Divide this by a scalar.

Definition at line 398 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00399     {
00400         val[0] /= f;
00401         val[1] /= f;
00402         return *this;
00403     }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator= ( const GLVector2< T > &  v  )  [inline]

copy this from a vector

Definition at line 406 of file GLVector.h.

References mathglpp::GLIVector2< T >::D, mathglpp::GLVector2< T >::val, and mathglpp::GLIVector2< T >::val.

00407     {   memmove(val, v.val, D*sizeof(T)); return *this; }

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::operator= ( const GLIVector2< T > &  v  )  [inline]

copy this from a vector

Definition at line 410 of file GLVector.h.

References mathglpp::GLIVector2< T >::D, and mathglpp::GLIVector2< T >::val.

00411     {   memmove(val, v.val, D*sizeof(T)); return *this; }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::operator- (  )  const [inline]

negate this

Definition at line 414 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00415     {
00416         return GLVector2<T>(-val[0],-val[1]);
00417     }

template<typename T>
const T mathglpp::GLIVector2< T >::dot ( const GLVector2< T > &  gv  )  const [inline]

Get the dot product of this and a vector.

Definition at line 420 of file GLVector.h.

References mathglpp::GLIVector2< T >::val, mathglpp::GLVector2< T >::x, and mathglpp::GLVector2< T >::y.

Referenced by mathglpp::GLIVector2< T >::projection(), and mathglpp::GLIVector2< T >::vectorProjection().

00421     {   return val[0]*gv.x + val[1]*gv.y; }

template<typename T>
const T mathglpp::GLIVector2< T >::dot ( const GLIVector2< T > &  gv  )  const [inline]

Get the dot product of this and a vector.

Definition at line 424 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

00425     {   return val[0]*gv.val[0] + val[1]*gv.val[1]; }

template<typename T>
T mathglpp::GLIVector2< T >::length (  )  const [inline]

Get the length of this.

Definition at line 428 of file GLVector.h.

References mathglpp::GLIVector2< T >::lengthSqr().

Referenced by mathglpp::GLIVector2< T >::normalize(), and mathglpp::GLIVector2< T >::unit().

00429     {   return sqrt(lengthSqr()); }

Here is the call graph for this function:

template<typename T>
T mathglpp::GLIVector2< T >::lengthSqr (  )  const [inline]

Get the length squared, less computation than length().

Definition at line 432 of file GLVector.h.

References mathglpp::GLIVector2< T >::val.

Referenced by mathglpp::GLIVector2< T >::length().

00433     {   return val[0]*val[0] + val[1]*val[1]; }

template<typename T>
const GLVector2<T> mathglpp::GLIVector2< T >::unit (  )  const [inline]

Get the the unit vector of this.

Definition at line 436 of file GLVector.h.

References mathglpp::GLIVector2< T >::length().

00437     {
00438         return (*this)/length();
00439     }

Here is the call graph for this function:

template<typename T>
GLIVector2& mathglpp::GLIVector2< T >::normalize (  )  [inline]

Normalize this, makes this a unit vector, US spelling.

Definition at line 442 of file GLVector.h.

References mathglpp::GLIVector2< T >::length().

00443     {
00444         (*this)/=length();
00445         return *this;
00446     }

Here is the call graph for this function:

template<typename T>
const T mathglpp::GLIVector2< T >::projection ( const GLVector2< T > &  in  )  const [inline]

Get the projection of this and a vector.

Definition at line 449 of file GLVector.h.

References mathglpp::GLIVector2< T >::dot().

00450     {   return dot(in); }

Here is the call graph for this function:

template<typename T>
const T mathglpp::GLIVector2< T >::projection ( const GLIVector2< T > &  in  )  const [inline]

Get the projection of this and a vector.

Definition at line 453 of file GLVector.h.

References mathglpp::GLIVector2< T >::dot().

00454     {   return dot(in); }

Here is the call graph for this function:

template<typename T>
GLVector2<T> mathglpp::GLIVector2< T >::orthogonalProjection ( const GLVector2< T > &  in  )  const [inline]

Get the orthogonal projection of this and a vector.

Definition at line 457 of file GLVector.h.

References mathglpp::GLIVector2< T >::vectorProjection().

00458     {   return in - vectorProjection(in); }

Here is the call graph for this function:

template<typename T>
GLVector2<T> mathglpp::GLIVector2< T >::orthogonalProjection ( const GLIVector2< T > &  in  )  const [inline]

Get the orthogonal projection of this and a vector.

Definition at line 461 of file GLVector.h.

References mathglpp::GLIVector2< T >::vectorProjection().

00462     {   return in - vectorProjection(in); }

Here is the call graph for this function:

template<typename T>
GLVector2<T> mathglpp::GLIVector2< T >::vectorProjection ( const GLVector2< T > &  in  )  const [inline]

Get the vector projection of this and a vector.

Definition at line 465 of file GLVector.h.

References mathglpp::GLIVector2< T >::dot().

Referenced by mathglpp::GLIVector2< T >::orthogonalProjection().

00466     {   return (*this) * dot(in); }

Here is the call graph for this function:

template<typename T>
GLVector2<T> mathglpp::GLIVector2< T >::vectorProjection ( const GLIVector2< T > &  in  )  const [inline]

Get the vector projection of this and a vector.

Definition at line 469 of file GLVector.h.

References mathglpp::GLIVector2< T >::dot().

00470     {   return (*this) * dot(in); }

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Wed Oct 3 12:50:53 2007 for MathGL++ by  doxygen 1.5.2