Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

pge::Vector3f Class Reference

#include <Vector3f.h>


Public Member Functions

 Vector3f (void)
 Standard constructor.

 Vector3f (float x, float y, float z)
 Vector3f (float v[3])
 Vector3f (const Vector3f &copy)
 Vector3f (const Vector4f &vec)
 ~Vector3f (void)
 Destructor.

Vector3f add (const Vector3f &v)
 Adds vector v to this and returns new vector.

Vector3f add (float c)
 Adds the constant c to this vector and returns a new vector.

Vector3f subtract (const Vector3f &v)
Vector3f subtract (float c)
Vector3f divide (const Vector3f &v)
Vector3f divide (float c)
Vector3f multiply (const Vector3f &v)
Vector3f multiply (float c)
float sqrMagnitude (void)
 Returns the squared magnitude.

float magnitude (void)
 Returns the magnitude.

float dotProduct (const Vector3f &v)
 Returns the dot product of this and the vector v.

void normalize (void)
 Normalize this vector.

Vector3f crossProduct (const Vector3f &v)
 Calculate the cross product.

float angle (Vector3f v)
 Returns the angle between this and the vector v.

float sqrDistance (const Vector3f &v)
 Returns the squared distance between this and the vector v.

float distance (const Vector3f &v)
 Returns the distance between this and the vector v.

bool isNullVector (void)
bool equals (const Vector3f &v)
 Returns 1 if the components of the vector euqal.

Vector3f closestPointOnLine (Vector3f lineStart, Vector3f lineEnd)
Vector3f createNormal (Vector3f a, Vector3f b, Vector3f c)
std::string toString (void)
 Debug print the components of the vector.

Vector3f operator+ (const Vector3f &v)
Vector3f operator- (const Vector3f &v)
Vector3f operator * (const Vector3f &v)
Vector3f operator * (float f)

Data Fields

float m_v [3]


Constructor & Destructor Documentation

pge::Vector3f::Vector3f void   ) 
 

Standard constructor.

Definition at line 16 of file Vector3f.cpp.

References m_v.

Referenced by add(), crossProduct(), divide(), multiply(), and subtract().

00016                                {
00017                 m_v[0] = 0.0f;
00018                 m_v[1] = 0.0f;
00019                 m_v[2] = 0.0f;
00020         }

pge::Vector3f::Vector3f float  x,
float  y,
float  z
 

Definition at line 28 of file Vector3f.cpp.

References m_v.

00028                                                     {
00029                 m_v[0] = x;
00030                 m_v[1] = y;
00031                 m_v[2] = z;
00032         }

pge::Vector3f::Vector3f float  v[3]  ) 
 

Definition at line 40 of file Vector3f.cpp.

References m_v.

00040                                      {
00041                 m_v[0] = v[0];
00042                 m_v[1] = v[1];
00043                 m_v[2] = v[2];
00044         }

pge::Vector3f::Vector3f const Vector3f copy  ) 
 

Definition at line 52 of file Vector3f.cpp.

References m_v.

00052                                                {
00053                 m_v[0] = copy.m_v[0];
00054                 m_v[1] = copy.m_v[1];
00055                 m_v[2] = copy.m_v[2];
00056         }

pge::Vector3f::Vector3f const Vector4f vec  ) 
 

Definition at line 64 of file Vector3f.cpp.

References pge::Vector4f::m_v, and m_v.

00064                                               {
00065                 m_v[0] = vec.m_v[0];
00066                 m_v[1] = vec.m_v[1];
00067                 m_v[2] = vec.m_v[2];
00068         }

pge::Vector3f::~Vector3f void   ) 
 

Destructor.

Definition at line 76 of file Vector3f.cpp.

00076                                 {
00077         }


Member Function Documentation

Vector3f pge::Vector3f::add float  c  ) 
 

Adds the constant c to this vector and returns a new vector.

Definition at line 96 of file Vector3f.cpp.

References m_v, and Vector3f().

00096                                       {
00097                 Vector3f res = Vector3f(m_v[0] + c, m_v[1] + c, m_v[2] + c);
00098                 return res;
00099         }

Here is the call graph for this function:

Vector3f pge::Vector3f::add const Vector3f v  ) 
 

Adds vector v to this and returns new vector.

Definition at line 85 of file Vector3f.cpp.

References m_v, and Vector3f().

Referenced by pge::Camera::applyCameraView(), pge::Camera::backward(), closestPointOnLine(), pge::Camera::down(), pge::Camera::forward(), operator+(), pge::Sprite::render(), pge::ParticleSystem::render(), pge::MeshModel::setBottomCenter(), pge::Camera::slideLeft(), pge::Camera::slideRight(), pge::Camera::up(), and pge::Camera::updatePhysics().

00085                                                 {
00086                 Vector3f res = Vector3f(m_v[0] + v.m_v[0], m_v[1] + v.m_v[1], m_v[2] + v.m_v[2]);
00087                 return res;
00088         }

Here is the call graph for this function:

float pge::Vector3f::angle Vector3f  v  ) 
 

Returns the angle between this and the vector v.

Definition at line 232 of file Vector3f.cpp.

References dotProduct(), magnitude(), and PIOVER180.

00232                                         {
00233                 return ((float)acos(dotProduct(v) / (magnitude() * v.magnitude())) / (float)PIOVER180);
00234         }

Here is the call graph for this function:

Vector3f pge::Vector3f::closestPointOnLine Vector3f  lineStart,
Vector3f  lineEnd
 

Definition at line 296 of file Vector3f.cpp.

References add(), distance(), dotProduct(), multiply(), normalize(), and subtract().

00296                                                                                   {
00297                 Vector3f c = this->subtract(lineStart);
00298                 Vector3f V = lineEnd.subtract(lineStart);
00299 
00300 
00301                 V.normalize();
00302                 float d = lineStart.distance(lineEnd);
00303                 float t = V.dotProduct(c);
00304 
00305                 // Check to see if t is beyond the extents of the line segment.
00306                 if(t < 0.0f) {
00307                         return lineStart;
00308                 }
00309                 if(t > d){ 
00310                         return lineEnd;
00311                 }
00312                 // Return the point between a and b.
00313                 // Set length of V to t.
00314                 V = V.multiply(t);
00315 
00316                 return lineStart.add(V);
00317         }

Here is the call graph for this function:

Vector3f pge::Vector3f::createNormal Vector3f  a,
Vector3f  b,
Vector3f  c
 

Definition at line 325 of file Vector3f.cpp.

References crossProduct(), normalize(), and subtract().

00325                                                                           {
00326                 Vector3f u;
00327                 Vector3f v;
00328                 Vector3f normal;
00329 
00330                 // Get the spanning vectors for the plane.
00331                 u = b.subtract(a);
00332                 v = c.subtract(a);
00333 
00334                 normal = u.crossProduct(v);
00335                 normal.normalize();
00336                 return normal;
00337         }

Here is the call graph for this function:

Vector3f pge::Vector3f::crossProduct const Vector3f v  ) 
 

Calculate the cross product.

Definition at line 220 of file Vector3f.cpp.

References m_v, and Vector3f().

Referenced by createNormal(), pge::Plane::Plane(), and pge::triangle::sameSide().

00220                                                          {
00221                 Vector3f res = Vector3f((m_v[1] * v.m_v[2]) - (m_v[2] * v.m_v[1]), (m_v[2] * v.m_v[0]) - (m_v[0] * v.m_v[2]),
00222                         (m_v[0] * v.m_v[1]) - (m_v[1] * v.m_v[0]));
00223                 return res;
00224         }

Here is the call graph for this function:

float pge::Vector3f::distance const Vector3f v  ) 
 

Returns the distance between this and the vector v.

Definition at line 254 of file Vector3f.cpp.

References m_v.

Referenced by closestPointOnLine(), and pge::SingleTexturedMesh::render().

00254                                                   {
00255                 return ((float)(sqrt(((m_v[0] - v.m_v[0]) * (m_v[0] - v.m_v[0])) +
00256                         ((m_v[1] - v.m_v[1]) * (m_v[1] - v.m_v[1])) +
00257                         ((m_v[2] - v.m_v[2]) * (m_v[2] - v.m_v[2]))
00258                         )));
00259         }

Vector3f pge::Vector3f::divide float  c  ) 
 

Definition at line 140 of file Vector3f.cpp.

References m_v, and Vector3f().

00140                                          {
00141                 Vector3f res = Vector3f(m_v[0] / c, m_v[1] / c, m_v[2] / c);
00142                 return res;
00143         }

Here is the call graph for this function:

Vector3f pge::Vector3f::divide const Vector3f v  ) 
 

Definition at line 129 of file Vector3f.cpp.

References m_v, and Vector3f().

Referenced by pge::Camera::updatePhysics().

00129                                                    {
00130                 Vector3f res = Vector3f(m_v[0] / v.m_v[0], m_v[1] / v.m_v[1], m_v[2] / v.m_v[2]);
00131                 return res;
00132         }

Here is the call graph for this function:

float pge::Vector3f::dotProduct const Vector3f v  ) 
 

Returns the dot product of this and the vector v.

Definition at line 193 of file Vector3f.cpp.

References m_v.

Referenced by angle(), closestPointOnLine(), pge::Plane::getDistanceToPoint(), pge::Plane::getFootPoint(), pge::Plane::getIntersectionPoint(), pge::Plane::Plane(), and pge::triangle::sameSide().

00193                                                     {
00194                 return ((m_v[0] * v.m_v[0]) + (m_v[1] * v.m_v[1]) + (m_v[2] * v.m_v[2]));
00195         }

bool pge::Vector3f::equals const Vector3f v  ) 
 

Returns 1 if the components of the vector euqal.

Definition at line 280 of file Vector3f.cpp.

References EQUAL_TOLERANCE, and m_v.

00280                                                {
00281                 if(abs(m_v[0] - v.m_v[0]) <= EQUAL_TOLERANCE
00282                         && abs(m_v[1] - v.m_v[1]) <= EQUAL_TOLERANCE
00283                         && abs(m_v[2] - v.m_v[2]) <= EQUAL_TOLERANCE) {
00284                                 return true;
00285                 } else {
00286                         return false;
00287                 }
00288         }

bool pge::Vector3f::isNullVector void   ) 
 

Definition at line 267 of file Vector3f.cpp.

References m_v.

00267                                         {
00268                 if (m_v[0] != 0.0f || m_v[1] != 0.0f || m_v[2] != 0.0f) {
00269                         return false;
00270                 }
00271                 return true;
00272         }

float pge::Vector3f::magnitude void   ) 
 

Returns the magnitude.

Definition at line 183 of file Vector3f.cpp.

References m_v.

Referenced by angle(), pge::Mesh::buildBoundingSphere(), pge::Sphere::getDistance(), and normalize().

00183                                       {
00184                 return ((float)sqrt((m_v[0] * m_v[0]) + (m_v[1] * m_v[1]) + (m_v[2] * m_v[2])));
00185         }

Vector3f pge::Vector3f::multiply float  c  ) 
 

Definition at line 162 of file Vector3f.cpp.

References m_v, and Vector3f().

00162                                            {
00163                 Vector3f res = Vector3f(m_v[0] * c, m_v[1] * c, m_v[2] * c);
00164                 return res;
00165         }

Here is the call graph for this function:

Vector3f pge::Vector3f::multiply const Vector3f v  ) 
 

Definition at line 151 of file Vector3f.cpp.

References m_v, and Vector3f().

Referenced by pge::Camera::backward(), closestPointOnLine(), pge::Camera::down(), pge::Camera::forward(), pge::DayNightCycle::getAmbientLight(), pge::Plane::getFootPoint(), operator *(), pge::ParticleSystem::render(), pge::MeshModel::scale(), pge::Camera::slideLeft(), pge::Camera::slideRight(), pge::Camera::up(), and pge::Camera::updatePhysics().

00151                                                      {
00152                 Vector3f res = Vector3f(m_v[0] * v.m_v[0], m_v[1] * v.m_v[1], m_v[2] * v.m_v[2]);
00153                 return res;
00154         }

Here is the call graph for this function:

void pge::Vector3f::normalize void   ) 
 

Normalize this vector.

Definition at line 203 of file Vector3f.cpp.

References m_v, and magnitude().

Referenced by closestPointOnLine(), createNormal(), pge::Plane::getIntersectionPoint(), pge::ParticleSystem::ParticleSystem(), pge::Plane::Plane(), pge::ParticleSystem::setDirection(), pge::Camera::slideLeft(), pge::Camera::slideRight(), pge::EffectTest::timer(), and pge::DayNightCycle::update().

00203                                      {
00204                 // calculate 1 / length of vector
00205                 float f = 1.0f / magnitude();
00206 
00207                 // multiply this value with the vector. this is the new normalized vector
00208                 m_v[0] = m_v[0] * f;
00209                 m_v[1] = m_v[1] * f;
00210                 m_v[2] = m_v[2] * f;
00211 
00212         }

Here is the call graph for this function:

Vector3f pge::Vector3f::operator * float  f  )  [inline]
 

Definition at line 122 of file Vector3f.h.

References multiply().

00122                                             {
00123                         return multiply(f);
00124                 }

Here is the call graph for this function:

Vector3f pge::Vector3f::operator * const Vector3f v  )  [inline]
 

Definition at line 115 of file Vector3f.h.

References multiply().

00115                                                       {
00116                         return multiply(v);
00117                 }

Here is the call graph for this function:

Vector3f pge::Vector3f::operator+ const Vector3f v  )  [inline]
 

Definition at line 101 of file Vector3f.h.

References add().

00101                                                       {
00102                         return add(v);
00103                 }

Here is the call graph for this function:

Vector3f pge::Vector3f::operator- const Vector3f v  )  [inline]
 

Definition at line 108 of file Vector3f.h.

References subtract().

00108                                                       {
00109                         return subtract(v);
00110                 }

Here is the call graph for this function:

float pge::Vector3f::sqrDistance const Vector3f v  ) 
 

Returns the squared distance between this and the vector v.

Definition at line 242 of file Vector3f.cpp.

References m_v.

Referenced by pge::SingleTexturedMesh::render(), and pge::ParticleSystem::render().

00242                                                      {
00243                 return ((m_v[0] - v.m_v[0]) * (m_v[0] - v.m_v[0])) +
00244                         ((m_v[1] - v.m_v[1]) * (m_v[1] - v.m_v[1])) +
00245                         ((m_v[2] - v.m_v[2]) * (m_v[2] - v.m_v[2]));
00246         }

float pge::Vector3f::sqrMagnitude void   ) 
 

Returns the squared magnitude.

Definition at line 173 of file Vector3f.cpp.

References m_v.

Referenced by pge::Sphere::getSquaredDistance().

00173                                          {
00174                 return ((m_v[0] * m_v[0]) + (m_v[1] * m_v[1]) + (m_v[2] * m_v[2]));
00175         }

Vector3f pge::Vector3f::subtract float  c  ) 
 

Definition at line 118 of file Vector3f.cpp.

References m_v, and Vector3f().

00118                                            {
00119                 Vector3f res = Vector3f(m_v[0] - c, m_v[1] - c, m_v[2] - c);
00120                 return res;
00121         }

Here is the call graph for this function:

Vector3f pge::Vector3f::subtract const Vector3f v  ) 
 

Definition at line 107 of file Vector3f.cpp.

References m_v, and Vector3f().

Referenced by pge::Mesh::buildBoundingSphere(), closestPointOnLine(), createNormal(), pge::Sphere::getDistance(), pge::Plane::getFootPoint(), pge::Plane::getIntersectionPoint(), pge::Sphere::getSquaredDistance(), operator-(), pge::Plane::Plane(), pge::Sprite::render(), pge::ParticleSystem::render(), pge::triangle::sameSide(), pge::MeshModel::setBottomCenter(), and pge::Camera::updatePhysics().

00107                                                      {
00108                 Vector3f res = Vector3f(m_v[0] - v.m_v[0], m_v[1] - v.m_v[1], m_v[2] - v.m_v[2]);
00109                 return res;
00110         }

Here is the call graph for this function:

std::string pge::Vector3f::toString void   ) 
 

Debug print the components of the vector.

Definition at line 345 of file Vector3f.cpp.

00345                                          {
00346                 //return std::string("X: " + m_v[0] + " Y: " + m_v[1] + " Z: " + m_v[2]);
00347                 return std::string("TODO");
00348         }


Field Documentation

float pge::Vector3f::m_v[3]
 

Definition at line 132 of file Vector3f.h.

Referenced by pge::Plane::a(), add(), pge::Camera::applyCameraPosition(), pge::Camera::applyCameraView(), pge::Plane::b(), pge::MeshModel::buildBoundingBox(), pge::Mesh::buildBoundingBox(), pge::Mesh::buildBoundingSphere(), pge::Plane::c(), pge::renderer::color3f(), pge::DynamicCity::createCity(), pge::meshfactory::createCuboid(), createGrass(), pge::DynamicCity::createGround(), pge::DynamicCity::createHouse(), crossProduct(), distance(), divide(), dotProduct(), equals(), pge::HeightmapLoader::generateTerrain(), pge::Mesh::getHeightAt(), pge::Plane::getIntersectionPoint(), pge::GPUWater::GPUWater(), pge::Plane::isLineIntersecting(), isNullVector(), pge::Frustum::isPointInside(), pge::AABB::isPointInside(), magnitude(), multiply(), pge::renderer::normal3f(), normalize(), pge::SGFFile::parseLight(), pge::SGFFile::parseMesh(), pge::GPUProgram::passUniform3f(), pge::Sprite::render(), pge::SkyBox::render(), pge::ParticleSystem::render(), pge::renderer::renderLine(), pge::renderer::renderQuad(), pge::ParticleSystem::resetParticle(), pge::Camera::revertCameraView(), pge::renderer::rotate(), pge::renderer::setClearColor(), pge::SGFFile::sgfLightToLight(), pge::Camera::slideLeft(), pge::Camera::slideRight(), sqrDistance(), sqrMagnitude(), subtract(), pge::ParticleSystem::timer(), pge::EffectTest::timer(), pge::renderer::translate(), pge::DayNightCycle::update(), pge::Camera::updateDirection(), pge::Camera::updatePhysics(), Vector3f(), pge::renderer::vertex3f(), and pge::renderer::wireSphere().


The documentation for this class was generated from the following files:
Generated on Mon Oct 16 12:09:53 2006 for Phobosengine by doxygen 1.3.4