00001
00002
00003 #ifndef _SPHERICAL_H_
00004 #define _SPHERICAL_H_
00005
00006 #include <stdlib.h>
00007 #include <string.h>
00008 #include <iostream.h>
00009
00010 #include "vuVector.h"
00011 #include "vuSimpleTypes.h"
00012
00014
00032 class vuSpherical
00033 {
00034 public:
00036 vuSpherical();
00038 vuSpherical(const vuSpherical& v);
00040 vuSpherical(float longitude, float latitude, float radius);
00042
00045 vuSpherical(const float* v);
00049 vuSpherical(vuVector &vector);
00051 ~vuSpherical();
00052
00054 vuSpherical& operator=(const vuSpherical& v);
00056 vuSpherical& operator=(const float* v);
00057
00059 float getLongitude() { return val[0]; }
00061 float getLatitude() { return val[1]; }
00063 float getRadius() { return val[2]; }
00064
00065
00067 void setLongitude(float _val) { val[0] = _val; }
00069 void setLatitude(float _val) { val[1] = _val; }
00071 void setRadius(float _val) { val[2] = _val; }
00072
00074 float norm(void) const;
00076
00078 float norm2(void) const;
00079
00081
00082 vuSpherical& makeUnit(void);
00083
00085 float& operator[](dword index);
00087 const float& operator[](dword index) const;
00088
00090
00096 float* getData(void);
00098 float const* getData(void) const;
00099
00101 bool operator==(const vuSpherical& v) const;
00103 bool operator!=(const vuSpherical& v) const;
00104
00106 friend ostream& operator<<(ostream& out,const vuSpherical& v);
00108 friend istream& operator>>(istream& in, vuSpherical& v);
00109
00111 void print();
00112
00114 vuVector getVector();
00115
00116 private:
00120 float val[3];
00121
00122 inline void ensure(float &longitude, float &latitude, float &radius);
00123 };
00124
00125 #endif