1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/////////////////////////////////////////////////////////////
// //
// Copyright (c) 2007-2014 by The University of Queensland //
// Centre for Geoscience Computing //
// http://earth.uq.edu.au/centre-geoscience-computing //
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://www.opensource.org/licenses/osl-3.0.php //
// //
/////////////////////////////////////////////////////////////
#include "Plane.h"
// --- system includes ---
#include <cmath>
using std::fabs;
Plane::Plane()
{
m_p=Vector3(0.0,0.0,0.0);
m_normal=Vector3(1.0,0.0,0.0);
}
/*!
construct plane from origin and normal
\param orig a point within the plane
\param normal the normal of the plane (will be normalized)
*/
Plane::Plane(const Vector3& orig,const Vector3& normal)
{
m_p=orig;
m_normal=normal.unit();
}
/*!
Get the distance of a point from the line
\param p the point
*/
double Plane::getDist(const Vector3& p) const
{
return fabs((p-m_p)*m_normal);
}
ostream& operator<< (ostream& ost, const Plane& P)
{
ost << P.m_p << "-" << P.m_normal;
return ost;
}
|