CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

Point3D.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: Point3D.h,v 1.3.4.1 2004/07/23 23:09:28 garren Exp $
00003 // ---------------------------------------------------------------------------
00004 //
00005 // This file is a part of the CLHEP - a Class Library for High Energy Physics.
00006 //
00007 // History:
00008 // 09.09.96 E.Chernyaev - initial version
00009 // 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
00010 //                        the functionality from CLHEP::Hep3Vector
00011 // 01.04.03 E.Chernyaev - CLHEP-1.9: template version
00012 //
00013 
00014 #ifndef HEP_POINT3D_H
00015 #define HEP_POINT3D_H
00016 
00017 #include <iosfwd>
00018 #include "CLHEP/Geometry/defs.h"
00019 #include "CLHEP/Vector/ThreeVector.h"
00020 #include "CLHEP/Geometry/BasicVector3D.h"
00021 
00022 namespace HepGeom {
00023 
00024   class Transform3D;
00025 
00034   template<class T>
00035   class Point3D : public BasicVector3D<T> {};
00036 
00043   template<>
00044   class Point3D<float> : public BasicVector3D<float> {
00045   public:
00048     Point3D() {}
00049 
00052     Point3D(float x, float y, float z) : BasicVector3D<float>(x,y,z) {}
00053 
00056     explicit Point3D(const float * a)
00057       : BasicVector3D<float>(a[0],a[1],a[2]) {}
00058 
00061     Point3D(const Point3D<float> & v) : BasicVector3D<float>(v) {}
00062 
00065     Point3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
00066 
00069     ~Point3D() {}
00070 
00073     Point3D<float> & operator=(const Point3D<float> & v) {
00074       set(v.x(),v.y(),v.z()); return *this;
00075     }
00076 
00079     Point3D<float> & operator=(const BasicVector3D<float> & v) {
00080       set(v.x(),v.y(),v.z()); return *this;
00081     }
00082 
00085     float distance2() const { return mag2(); }
00086 
00089     float distance2(const Point3D<float> & p) const {
00090       float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
00091       return dx*dx + dy*dy + dz*dz;
00092     }
00093 
00096     float distance() const { return sqrt(distance2()); }
00097 
00100     float distance(const Point3D<float> & p) const {
00101       return sqrt(distance2(p));
00102     }
00103 
00106     Point3D<float> & transform(const Transform3D & m);
00107   };
00108 
00113   Point3D<float>
00114   operator*(const Transform3D & m, const Point3D<float> & p);
00115 
00122   template<>
00123   class Point3D<double> : public BasicVector3D<double> {
00124   public:
00127     Point3D() {}
00128 
00131     Point3D(double x, double y, double z) : BasicVector3D<double>(x,y,z) {}
00132 
00135     explicit Point3D(const float * a)
00136       : BasicVector3D<double>(a[0],a[1],a[2]) {}
00137 
00140     explicit Point3D(const double * a)
00141       : BasicVector3D<double>(a[0],a[1],a[2]) {}
00142 
00145     Point3D(const Point3D<double> & v) : BasicVector3D<double>(v) {}
00146 
00149     Point3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
00150 
00153     Point3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
00154 
00157     ~Point3D() {}
00158 
00164     Point3D(const CLHEP::Hep3Vector & v)
00165       : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
00166 
00172     operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
00173 
00176     Point3D<double> & operator=(const Point3D<double> & v) {
00177       set(v.x(),v.y(),v.z()); return *this;
00178     }
00179 
00182     Point3D<double> & operator=(const BasicVector3D<float> & v) {
00183       set(v.x(),v.y(),v.z()); return *this;
00184     }
00185 
00188     Point3D<double> & operator=(const BasicVector3D<double> & v) {
00189       set(v.x(),v.y(),v.z()); return *this;
00190     }
00191 
00194     double distance2() const { return mag2(); }
00195 
00198     double distance2(const Point3D<double> & p) const {
00199       double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
00200       return dx*dx + dy*dy + dz*dz;
00201     }
00202 
00205     double distance() const { return sqrt(distance2()); }
00206 
00209     double distance(const Point3D<double> & p) const {
00210       return sqrt(distance2(p));
00211     }
00212 
00215     Point3D<double> & transform(const Transform3D & m);
00216   };
00217 
00222   Point3D<double>
00223   operator*(const Transform3D & m, const Point3D<double> & p);
00224 
00225 } /* namespace HepGeom */
00226 
00227 
00228 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
00229 //  backwards compatibility will be enabled ONLY in CLHEP 1.9
00230 #include "CLHEP/config/CLHEP.h"
00231 #include "CLHEP/Geometry/Normal3D.h"
00232 #include "CLHEP/Geometry/Transform3D.h"
00233 typedef HepGeom::Point3D<double> HepPoint3D;
00234 #endif
00235 
00236 #endif /* HEP_POINT3D_H */

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7