[80]  1  /**********************************************************************


 2  *<


 3  FILE: dpoint3.h


 4 


 5  DESCRIPTION:


 6 


 7  CREATED BY: Dan Silva


 8 


 9  HISTORY:


 10 


 11  *> Copyright (c) 1994, All Rights Reserved.


 12  **********************************************************************/


 13 


 14  #ifndef __DPOINT3__


 15 


 16  #define __DPOINT3__


 17 


 18  class ostream;


 19 


 20  class DPoint3 {


 21  public:


 22  double x,y,z;


 23 


 24  // Constructors


 25  DPoint3(){}


 26  DPoint3(double X, double Y, double Z) { x = X; y = Y; z = Z; }


 27  DPoint3(const DPoint3& a) { x = a.x; y = a.y; z = a.z; }


 28  DPoint3(double af[3]) { x = af[0]; y = af[1]; z = af[2]; }


 29 


 30  // Access operators


 31  double& operator[](int i) { return (&x)[i]; }


 32  const double& operator[](int i) const { return (&x)[i]; }


 33 


 34  // Conversion function


 35  operator double*() { return(&x); }


 36 


 37  // Unary operators


 38  DPoint3 operator() const { return(DPoint3(x,y,z)); }


 39  DPoint3 operator+() const { return *this; }


 40 


 41  // Assignment operators


 42  DllExport DPoint3& operator=(const DPoint3&);


 43  DllExport DPoint3& operator+=(const DPoint3&);


 44  DllExport DPoint3& operator*=(double);


 45  DllExport DPoint3& operator/=(double);


 46 


 47  // Binary operators


 48  DllExport DPoint3 operator(const DPoint3&) const;


 49  DllExport DPoint3 operator+(const DPoint3&) const;


 50  DllExport double operator*(const DPoint3&) const; // DOT PRODUCT


 51  DllExport DPoint3 operator^(const DPoint3&) const; // CROSS PRODUCT


 52 


 53  };


 54 


 55  double DllExport Length(const DPoint3&);


 56  int DllExport MaxComponent(const DPoint3&); // the component with the maximum abs value


 57  int DllExport MinComponent(const DPoint3&); // the component with the minimum abs value


 58  DPoint3 DllExport Normalize(const DPoint3&); // Return a unit vector.


 59 


 60  DPoint3 DllExport operator*(double, const DPoint3&); // multiply by scalar


 61  DPoint3 DllExport operator*(const DPoint3&, double); // multiply by scalar


 62  DPoint3 DllExport operator/(const DPoint3&, double); // divide by scalar


 63 


 64  ostream DllExport &operator<<(ostream&, const DPoint3&);


 65 


 66  // Inlines:


 67 


 68  inline double Length(const DPoint3& v) {


 69  return (double)sqrt(v.x*v.x+v.y*v.y+v.z*v.z);


 70  }


 71 


 72  inline DPoint3& DPoint3::operator=(const DPoint3& a) {


 73  x = a.x; y = a.y; z = a.z;


 74  return *this;


 75  }


 76 


 77  inline DPoint3& DPoint3::operator+=(const DPoint3& a) {


 78  x += a.x; y += a.y; z += a.z;


 79  return *this;


 80  }


 81 


 82  inline DPoint3& DPoint3::operator*=(double f) {


 83  x *= f; y *= f; z *= f;


 84  return *this;


 85  }


 86 


 87  inline DPoint3& DPoint3::operator/=(double f) {


 88  x /= f; y /= f; z /= f;


 89  return *this;


 90  }


 91 


 92  inline DPoint3 DPoint3::operator(const DPoint3& b) const {


 93  return(DPoint3(xb.x,yb.y,zb.z));


 94  }


 95 


 96  inline DPoint3 DPoint3::operator+(const DPoint3& b) const {


 97  return(DPoint3(x+b.x,y+b.y,z+b.z));


 98  }


 99 


 100  inline double DPoint3::operator*(const DPoint3& b) const {


 101  return(x*b.x+y*b.y+z*b.z);


 102  }


 103 


 104  inline DPoint3 operator*(double f, const DPoint3& a) {


 105  return(DPoint3(a.x*f, a.y*f, a.z*f));


 106  }


 107 


 108  inline DPoint3 operator*(const DPoint3& a, double f) {


 109  return(DPoint3(a.x*f, a.y*f, a.z*f));


 110  }


 111 


 112  inline DPoint3 operator/(const DPoint3& a, double f) {


 113  return(DPoint3(a.x/f, a.y/f, a.z/f));


 114  }


 115 


 116  DPoint3 DllExport CrossProd(const DPoint3& a, const DPoint3& b); // CROSS PRODUCT


 117 


 118  double DllExport DotProd(const DPoint3& a, const DPoint3& b) ; // DOT PRODUCT


 119 


 120  #endif


 121 

