CLHEP/Geometry/Point3D.h

// -*- C++ -*-
// $Id: Point3D.h,v 1.9 2001/06/14 13:40:48 evc Exp $
// ---------------------------------------------------------------------------
//
// This file is a part of the CLHEP - a Class Library for High Energy Physics.
//
// Geometrical 3D Point class.
//
// Author: Evgeni Chernyaev <Evgueni.Tcherniaev@cern.ch>
//
// History:
// 09.09.96 E.Chernyaev - initial version
// 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
//                        the functionality from Hep3Vector
//

#ifndef HEP_POINT3D_H
#define HEP_POINT3D_H

#include "CLHEP/config/CLHEP.h"
#include "CLHEP/Geometry/BasicVector3D.h"

class HepTransform3D;

class HepPoint3D : public BasicVector3D {       
 public:
  // Default constructor
  HepPoint3D() {}

  // Constructor from three doubles
  HepPoint3D(double x, double y, double z) : BasicVector3D(x,y,z) {}

  // Constructor from base class
  HepPoint3D(const BasicVector3D & v) : BasicVector3D(v) {}

  // Constructor from Hep3Vector
  HepPoint3D(const Hep3Vector & v) : BasicVector3D(v) {}

  // Destructor
  ~HepPoint3D() {}

  // Assignment
  HepPoint3D & operator=(const HepPoint3D & v) {
    set(v.x(),v.y(),v.z()); return *this;
  }

  // Assignment from BasicVector3D and
  // classes derived from it (Vector3D, Normal3D)
  HepPoint3D & operator=(const BasicVector3D & v) {
    set(v.x(),v.y(),v.z()); return *this;
  }
 
  // Distance squared to the origin
  double distance2() const { return mag2(); }

  // Distance squared to the point
  double distance2(const HepPoint3D & p) const {
    double delx = p.x()-x(), dely = p.y()-y(), delz = p.z()-z();
    return delx*delx + dely*dely + delz*delz;
  }

  // Distance to the origin
  double distance() const { return sqrt(distance2()); }

  // Distance to the point
  double distance(const HepPoint3D & p) const { return sqrt(distance2(p)); }

  // Transformation
  HepPoint3D & transform(const HepTransform3D &m);
};

#include "CLHEP/Geometry/Transform3D.h"

inline HepPoint3D & HepPoint3D::transform(const HepTransform3D & m) {
  return *this = m * (*this);
}

#endif /* HEP_POINT3D_H */

Generated by GNU enscript 1.6.1.