Al's Programming Resource Homepage  Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

vector.cpp

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <cmath>
00003 #include "vector.h"
00004 
00005 
00006 VECTOR::VECTOR(float sx, float sy, float sz)
00007 :
00008     x(sx),
00009     y(sy),
00010     z(sz)
00011 {
00012 }
00013 
00014 VECTOR::VECTOR(const VECTOR& Vector)
00015 {
00016     x = Vector.x;
00017     y = Vector.y;
00018     z = Vector.z;
00019 }
00020 
00021 VECTOR::~VECTOR()
00022 {
00023 }
00024 
00025 void VECTOR::Reset()
00026 {
00027     x = 0;
00028     y = 0;
00029     z = 0;
00030 }
00031 
00032 float VECTOR::DotProduct(VECTOR vect)
00033 {
00034       float dot;
00035       dot = vect.x * x + vect.y * y + vect.z * z;
00036       return dot;
00037 }
00038 
00039 void VECTOR::CrossVector(VECTOR vect)
00040 {
00041       VECTOR temp = *this;
00042       x = vect.y * temp.z - vect.z * temp.y;
00043       y = vect.z * temp.x - vect.x * temp.z;
00044       z = vect.x * temp.y - vect.y * temp.x;
00045 }
00046 
00047 float VECTOR::GetMagnitude()
00048 {
00049     float magnitude = (float)sqrt(x * x + y * y + z * z);
00050     if (magnitude != 0.0f)
00051         return magnitude;
00052     else
00053         return 0.000001;
00054 }
00055 
00056 void VECTOR::Normalize()
00057 {
00058     float magnitude = this->GetMagnitude();
00059     x /= magnitude;
00060     y /= magnitude;
00061     z /= magnitude;
00062 }

Generated on Fri Dec 23 05:20:59 2005 for Polygon Selection by doxygen1.2.15