PHPoint.C
//---------------------------------------------------------------------------------------
//
// Includes: PHPoint.h
//
// Created by: Jane M. Burward-Hoy and Federica Messer
//
// Purpose: The constructor, destructor, copy constructor, assignment, subtraction,
// addition, and distance functions are defined here. These functions are
// member functions of the PHPoint class.
//
// Last update: 10/19/99
//
#include "PHPoint.h"
#include "PHGeometron.h"
PHPoint::PHPoint()
{
setX(0);
setY(0);
setZ(0);
}
PHPoint::PHPoint(double x, double y, double z)
{
setX(x);
setY(y);
setZ(z);
}
PHPoint::~PHPoint()
{
}
PHPoint::PHPoint(const PHPoint &p)
{
setX(p.x());
setY(p.y());
setZ(p.z());
}
PHPoint::PHPoint(const PHVector &p)
{
setX(p.getX());
setY(p.getY());
setZ(p.getZ());
}
PHPoint::PHPoint(const PHSphPoint &sph)
{
PHGeometron* geometry = PHGeometron::instance();
geometry->sphericalToCartesian(sph,*this);
}
PHPoint::PHPoint(const PHCylPoint &cyl)
{
PHGeometron* geometry = PHGeometron::instance();
geometry->cylindricalToCartesian(cyl,*this);
}
PHPoint& PHPoint::operator=(const PHPoint &p)
{
setX(p.getX());
setY(p.getY());
setZ(p.getZ());
return *this;
}
PHPoint& PHPoint::operator=(const PHVector &p)
{
setX(p.getX());
setY(p.getY());
setZ(p.getZ());
return *this;
}
PHPoint & PHPoint::operator=(const PHSphPoint &sph)
{
PHGeometron* geometry = PHGeometron::instance();
geometry->sphericalToCartesian(sph,*this);
return *this;
}
PHPoint & PHPoint::operator=(const PHCylPoint &cyl)
{
PHGeometron* geometry = PHGeometron::instance();
geometry->cylindricalToCartesian(cyl,*this);
return *this;
}
PHPoint & PHPoint::operator=(const HepPoint3D &p)
{
setX(p.x());
setY(p.y());
setZ(p.z());
return *this;
}
PHPoint& PHPoint::operator=(const Hep3Vector &v)
{
setX(v.x());
setY(v.y());
setZ(v.z());
return *this;
}
PHPoint PHPoint::operator-(const PHPoint &p) const
{
PHPoint newPoint;
newPoint.setX(getX()-p.x());
newPoint.setY(getY()-p.y());
newPoint.setZ(getZ()-p.z());
return newPoint;
}
PHPoint PHPoint::operator- ()
{
setX(-getX());
setY(-getY());
setZ(-getZ());
return *this;
}
PHPoint PHPoint::operator*(const double &a) const
{
PHPoint newPoint;
newPoint.setX(getX()*a);
newPoint.setY(getY()*a);
newPoint.setZ(getZ()*a);
return newPoint;
}
PHPoint PHPoint::operator+(const PHPoint &p) const
{
PHPoint newPoint;
newPoint.setX(getX()+p.x());
newPoint.setY(getY()+p.y());
newPoint.setZ(getZ()+p.z());
return newPoint;
}
ostream& operator<<(ostream& os, const PHPoint &p)
{
return (os << "( " << p.getX() << ", " << p.getY() << ", " << p.getZ() << " ) ");
}
double PHPoint::distanceToPoint(const PHPoint &p) const
{
PHGeometron *geometry = PHGeometron::instance();
return (geometry->distancePointToPoint(p,*this));
}
void PHPoint::print() const
{
cout << "( " << getX() << ", " << getY() << ", " << getZ() << " ) " << endl;
}