Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Beta/Math/Vector/Vector3.hpp

Go to the documentation of this file.
00001 #ifndef __J2K__Vector3_HPP__
00002 #define __J2K__Vector3_HPP__
00003 
00004 #include <j2k/Fred/Basic.hpp>
00005 #include <j2k/Fred/Boolean.hpp>
00006 #include <j2k/Fred/StdTypes.hpp>
00007 #include <math.h>
00008 
00009 #ifndef __J2K__Vector2_HPP__
00010   class JVector2;
00011   class JVector3;
00012 #endif
00013 
00014 class JVector3
00015 {
00016  public:
00017   double v[3]; // vector array
00018   
00019   // constructors
00020         JVector3() {}
00021 
00022   JVector3(const JVector3& obj);
00023 
00024   JVector3(const JVector2& obj);
00025   
00026   JVector3(double x, double y, double z){
00027      v[0] = x;
00028      v[1] = y;
00029      v[2] = z;
00030   }
00031   
00032   virtual ~JVector3() {}
00033   
00034   void print();
00035   void add(JVector3);
00036   void subtract(JVector3);
00037   void multiply(double);
00038   void divide(double);
00039   double dot(JVector3);
00040   void cross(JVector3);
00041   
00042   void negative();
00043   double length();
00044   void unit();
00045   
00046   double comp(JVector3);
00047   JVector3 proj(JVector3);
00048   
00049   // operators
00050   double&  operator[](int); // return index
00051   JVector3 operator()(double, double, double); // assign doubles
00052   
00053   JVector3 operator+(JVector3); // add
00054   JVector3 operator-(JVector3); // subtract
00055   JVector3 operator*(double); // multiply
00056   friend JVector3 operator*(double, JVector3);
00057   JVector3 operator/(double); // divide
00058   friend JVector3 operator/(double, JVector3);
00059   double operator*(JVector3); // dot product
00060   JVector3 operator%(JVector3); // cross product 
00061   
00062   void operator+=(JVector3 val) { add(val); }
00063   void operator-=(JVector3 val) { subtract(val); }
00064   void operator*=(double val) { multiply(val); }
00065   void operator/=(double val) { divide(val); }
00066   void operator%=(JVector3 val) { cross(val); }
00067   
00068   JVector3 operator-(); // negation
00069   double operator!(); // absolute value, length
00070   JVector3 operator~(); // unit vector
00071   
00072   BOOL operator==(JVector3 val) 
00073   {
00074     if (v[0] == val.v[0])
00075       if (v[1] == val.v[1])
00076    if (v[2] == val.v[2])
00077           return TRUE;
00078     
00079     return FALSE;
00080   }
00081 };
00082 
00083 #ifndef __J2K__Vector2_HPP__
00084   #include <j2k/Fred/Math/Vector/Vector2.hpp>
00085   #include <j2k/Fred/Math/Vector/Vector2.cpp>
00086 #endif
00087 
00088 #endif

Generated on Sun Oct 14 18:46:16 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001