Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Point.h

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/geometry/geometry/Point.h,v 1.3 2001/10/06 03:37:05 burnett Exp $
00002 //   Author: T. Burnett
00003 //  Project: geometry
00004 //
00005 
00006 #ifndef GEOMETRY_POINT_H
00007 #define GEOMETRY_POINT_H
00008 
00009 #include "geometry/Vector.h"
00010 
00014 class Point: public Hep3Vector , public GeomObject
00015 {
00016 public:
00017     Point(const Point& p):Hep3Vector(p),GeomObject(){}
00018     Point():Hep3Vector(0,0,0){}
00019     Point(double x, double y, double z):Hep3Vector(x,y,z){}
00020     // constructors: default is null
00021     
00022     Point& operator=(const Point& v){return (Point&)Hep3Vector::operator=(v);}
00023     Point& operator+=(const Vector& v){return (Point&)Hep3Vector::operator+=(v);}
00024     Point& operator-=(const Vector& v){return (Point&)Hep3Vector::operator-=(v);}
00025     // assignment operators: allow  V = P - P, P = P + V, P = P - V
00026     
00027     //(uneeded?) operator Vector()const{return Vector(x(),y(),z());}
00028     // operator that converts to a vector
00029     
00030     GeomObject& transform(const CoordTransform&);
00031     // transforms like a point
00032     
00033     
00034     const char* nameOf()const{return "Point";}
00035     void printOn(std::ostream& f =std::cout)const;
00036     
00037 private:
00038     // make illegal operations unaccessible that would inherit from Hep3Vector
00039     Point operator*(double ){return Point();}  // no multiply
00040     Point operator/(double ){return Point();}  // or divide
00041     Point operator+(const Point& ){return Point();}; // or add another Point
00042     
00043 };
00044 
00045 // resolve ambiguity bet. GeomObject and Hep3Vector
00046 inline std::ostream& operator<<(std::ostream& out, const Point& v)
00047 {  v.printOn(out); return out;}
00048 
00049 // allow  legal addition, subtraction
00050 
00051 inline Point operator - (const Point & a, const Vector & b) {
00052     Point p(a.x() - b.x(), a.y() - b.y(), a.z() - b.z());  return p;}
00053 
00054 inline Vector operator - (const Point & a, const Point & b) {
00055     Vector v(a.x() - b.x(), a.y() - b.y(), a.z() - b.z());  return v;}
00056 
00057 inline Point operator + (const Point & a, const Vector & b) {
00058     Point p(a.x() + b.x(), a.y() + b.y(), a.z() + b.z());  return p;}
00059 
00060 inline Point operator + (const Vector & a, const Point & b) {
00061     Point p(a.x() + b.x(), a.y() + b.y(), a.z() + b.z());  return p;}
00062 
00063 
00064 
00065 
00066 
00067 #endif
00068 

Generated at Wed Nov 21 12:20:12 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000