PHPlane.C
//-----------------PHPlane class source code-----------------------------
// Class: includes PHPlane header
//
// Created by: Jane M. Burward-Hoy and Federica Messer
//
// Purpose: The Phenix plane class, PHPlane is declared here.
//
// A plane is defined by a local coordinate origin point
// and a unit vector normal to the plane. The equation
// of a plane is aX + bY + cZ + d = 0, where a, b, c,
// and d are the magnitudes of the unit vector normal to
// the plane.
// Last update: 10/25/99
//
#include <math.h>
#include "PHPlane.h"
PHPlane::PHPlane()
{
}
PHPlane::PHPlane(const PHPoint &p, const PHVector &v)
{
origin = p;
normal = v;
normalize();
}
PHPlane::PHPlane(const PHPlane& plane)
{
origin = plane.origin;
normal = plane.normal;
}
PHPlane::PHPlane(const PHLine& line)
{
origin = line.getBasepoint();
normal = line.getDirection();
}
PHPlane& PHPlane::operator=(const PHPlane &rhs)
{
origin = rhs.origin;
normal = rhs.normal;
return *this;
}
PHPlane& PHPlane::operator=(const PHLine &rhs)
{
origin = rhs.getBasepoint();
normal = rhs.getDirection();
return *this;
}
PHPlane::~PHPlane()
{
}
void PHPlane::print()
{
cout << "PHPlane:\n";
cout << " Origin = " << origin;
cout << " Normal = " << normal;
}
void PHPlane::setNormal(PHVector &v)
{
normal = v;
if ( (normal.length()!=1) && (normal.length()!=0.0) )
normalize();
}
double PHPlane::getD()
{
PHVector v;
v = origin;
return -normal.dot(v);
}