Vector.h

Go to the documentation of this file.
00001 /*
00002  * Datei: Vector.h
00003  *
00004  * Autor: Gradwohl Manuel (Matr. Nr. 0425062/Kennz. 532)
00005  *        Pickelbauer Michael (Matr. Nr. 0425061/Kennz. 534)
00006  *
00007  * Beschreibung: stellt Datenstruktur für einen Vektor zur Verfügung und zusätzliche Hilfsfunktionen
00008  * 
00009  */
00010 
00011 #pragma once
00012 
00013 #define PI 3.141592654
00014 
00015 #include "math.h"
00016 
00020 class Vector{
00021         Vector matrixMult(float m[3][3]);
00022 public:
00023         float x;
00024         float y;
00025         float z;
00026         Vector();
00027         Vector(float _x, float _y, float _z);
00028         Vector(Vector *v);
00029         ~Vector();
00030         Vector *crossProduct(Vector *v2);
00031         float dotProduct(Vector *v2);
00032         Vector *add(Vector *v2);
00033         Vector *sub(Vector *v2);
00034         void normalize();
00035         float GetLength();
00036         Vector operator -(Vector &v2);
00037         Vector operator +(Vector &v2);
00038         Vector *multScalar(float scalar);
00039         Vector rotateX(float angle);
00040         Vector rotateY(float angle);
00041         Vector rotateZ(float angle);
00042         Vector scale(float sx, float sy, float sz);
00043 
00044         Vector& operator+=( Vector &v2 )
00045         {
00046                 x += v2.x;
00047                 y += v2.y;
00048                 z += v2.z;
00049 
00050                 return *this;
00051         }
00052 
00053         Vector& operator-=( Vector &v2 )
00054         {
00055                 x -= v2.x;
00056                 y -= v2.y;
00057                 z -= v2.z;
00058 
00059                 return *this;
00060         }
00061 
00062         Vector& operator*=(float scalar){
00063                 x *= scalar;
00064                 y *= scalar;
00065                 z *= scalar;
00066 
00067                 return *this;
00068         }
00069 
00070         Vector& operator/=(float scalar){
00071                 x /= scalar;
00072                 y /= scalar;
00073                 z /= scalar;
00074 
00075                 return *this;
00076         }
00077 
00078         float magnitude(void);
00079         void set(float p_x, float p_y, float p_z);
00080         void set(Vector* v);
00081 
00082         float getAngle() {
00083                 float len = GetLength();
00084                 if( len == 0 )
00085                         return 0;
00086                 else
00087                 {
00088                         float ny;
00089                         ny = y/len;
00090 
00091                         if( x > 0 )
00092                                 return (float) (asin(ny)*360/(2*PI));
00093                         else
00094                                 return (float) 180 - (asin(ny)*360/(2*PI));
00095                 }
00096         };
00097 
00098 };

Generated on Wed Jan 17 11:58:35 2007 for VisLuBsp1 by  doxygen 1.5.1-p1