Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

WPCG::WP_Vector2D Class Reference

#include <WP_Vector2D.h>

List of all members.

Public Methods

 WP_Vector2D ()
 WP_Vector2D (scalar x, scalar y)
 ~WP_Vector2D ()
WP_Vector2D & operator= (const WP_Vector2D &v)
scalar operator * (const WP_Vector2D &v) const
WP_Vector2D operator * (scalar s) const
WP_Vector2D operator/ (scalar s) const
WP_Vector2D operator- (const WP_Vector2D &v) const
WP_Vector2D operator+ (const WP_Vector2D &v) const
WP_Vector2D & operator- ()
WP_Vector2D & operator-= (const WP_Vector2D &v)
WP_Vector2D & operator+= (const WP_Vector2D &v)
WP_Vector2D & operator *= (scalar s)
WP_Vector2D & operator/= (scalar s)
WP_Vector2D & operator *= (const WP_Matrix2D &m)
WP_Vector2D operator * (const WP_Matrix2D &m) const
scalar length () const
scalar normalize ()
void perp ()
scalar getDegreesBetween (const WP_Vector2D &v) const
scalar getRadsBetween (const WP_Vector2D &v) const
bool orthogonal (const WP_Vector2D &v) const
void richochet (WP_Vector2D v)
void draw (scalar startx, scalar starty) const

Public Attributes

scalar data [3]


Detailed Description

this class represents a 2D vector
Author:
Copyright (C) 2001 W.P. van Paassen peter@paassen.tmfweb.nl
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


Constructor & Destructor Documentation

WPCG::WP_Vector2D::WP_Vector2D  
 

WPCG::WP_Vector2D::WP_Vector2D scalar    x,
scalar    y
 

Parameters:
x  the x component of the vector
y  the y component of the vector

WPCG::WP_Vector2D::~WP_Vector2D   [inline]
 


Member Function Documentation

void WPCG::WP_Vector2D::draw scalar    startx,
scalar    starty
const
 

this function draws the vector using OpenGL

Parameters:
startx  the x position of the start of this vector
starty  the y position of the start of this vector

scalar WPCG::WP_Vector2D::getDegreesBetween const WP_Vector2D &    v const
 

this function computes the angle in degrees between two vectors

Parameters:
v  a WP_Vector2D object representing the second vector for calculating the angle between two vectors
Returns:
the angle in degrees

scalar WPCG::WP_Vector2D::getRadsBetween const WP_Vector2D &    v const
 

this function computes the angle in radians between two vectors

Parameters:
v  a WP_Vector2D object representing the second vector for calculating the angle between two vectors
Returns:
the angle in radians

scalar WPCG::WP_Vector2D::length   const
 

this function computes the length of the vector

Returns:
the lenght of the vector

scalar WPCG::WP_Vector2D::normalize  
 

this function normalizes the vector

Returns:
the lenght of the vector before normalizing

WP_Vector2D WPCG::WP_Vector2D::operator * const WP_Matrix2D   m const
 

this operator multiplies this vector by a 2D matrix

Parameters:
m  a WP_Matrix2D object which represents the 2D matrix by which this vector is multiplied
Returns:
a WP_Vector2D object containing the new values

WP_Vector2D WPCG::WP_Vector2D::operator * scalar    s const
 

this operator scales the vector by multiplying its values by a scalar

Parameters:
s  the scalar by which this vector is scaled
Returns:
a WP_Vector2D object representing the scaled vector

scalar WPCG::WP_Vector2D::operator * const WP_Vector2D &    v const
 

this operator computes the dot product of the two 2D vectors

Parameters:
v  a WP_Vector2D object representing a vector by which this vector is multiplied to get the dot product
Returns:
the dot product

WP_Vector2D & WPCG::WP_Vector2D::operator *= const WP_Matrix2D   m
 

this operator multiplies this vector by a 2D matrix

Parameters:
m  a WP_Matrix2D object which represents the 2D matrix by which this vector is multiplied
Returns:
a reference to this WP_Vector2D object containing the new values

WP_Vector2D & WPCG::WP_Vector2D::operator *= scalar    s
 

this operator scales this vector by using multiplication

Parameters:
s  the scalar by which this vector is scaled
Returns:
a reference to this WP_Vector2D object containing the new values

WP_Vector2D WPCG::WP_Vector2D::operator+ const WP_Vector2D &    v const
 

this operator adds a vector to this vector

Parameters:
v  a WP_Vector2D object representing the vector which is added to this vector
Returns:
a WP_Vector2D object representing the vector after addition

WP_Vector2D & WPCG::WP_Vector2D::operator+= const WP_Vector2D &    v
 

this operator adds a vector to this vector and assigns the result to this vector

Parameters:
v  a WP_Vector2D object representing the vector which is added to this vector
Returns:
a reference to this WP_Vector2D object containing the new values

WP_Vector2D & WPCG::WP_Vector2D::operator-  
 

this operator inverts the vector

Returns:
a reference to this WP_Vector2D object containing the inverted values

WP_Vector2D WPCG::WP_Vector2D::operator- const WP_Vector2D &    v const
 

this operator subtracts a vector from this vector

Parameters:
v  a WP_Vector2D object representing the vector which is subtracted from this vector
Returns:
a WP_Vector2D object representing the vector after subtraction

WP_Vector2D & WPCG::WP_Vector2D::operator-= const WP_Vector2D &    v
 

this operator subtracts a vector from this vector and assigns the result to this vector

Parameters:
v  a WP_Vector2D object representing the vector which is subtracted from this vector
Returns:
a reference to this WP_Vector2D object containing the new values

WP_Vector2D WPCG::WP_Vector2D::operator/ scalar    s const
 

this operator scales the vector by dividing its values by a scalar

Parameters:
s  the scalar by which this vector is scaled
Returns:
a WP_Vector2D object representing the scaled vector

WP_Vector2D & WPCG::WP_Vector2D::operator/= scalar    s
 

this operator scales this vector by using division

Parameters:
s  the scalar by which this vector is scaled
Returns:
a reference to this WP_Vector2D object containing the new values

WP_Vector2D & WPCG::WP_Vector2D::operator= const WP_Vector2D &    v
 

assignment operator

Parameters:
v  the WP_Vector2D object which is copied to this object
Returns:
a reference to this object containing the copied vector values

bool WPCG::WP_Vector2D::orthogonal const WP_Vector2D &    v const
 

this function determines if two vectors are orthogonal (dot product is +- 0.0)

Parameters:
v  a WP_Vector2D object representing the second vector for calculating if the two vectors are orthogonal
Returns:
a boolean indicating if the two vectors are orthogonal

void WPCG::WP_Vector2D::perp  
 

this function makes the vector perpendicular to itself (or rotates the vector 90 degrees)

void WPCG::WP_Vector2D::richochet WP_Vector2D    v
 

this function computes the new vector after colliding to a line/plane/surface

Parameters:
v  a WP_Vector2D object which represents the normal of the line/plane/surface against which this vector collides


Member Data Documentation

scalar WPCG::WP_Vector2D::data[3]
 

an array of 3 scalars holding the vector's values. data[0] = x, data[1] = y, data[2] = 0.0f


The documentation for this class was generated from the following files:
Generated on Tue Jan 28 20:26:44 2003 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002