~ubuntu-branches/ubuntu/saucy/python-demgengeo/saucy

« back to all changes in this revision

Viewing changes to geometry/Plane.cc

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2011-11-18 21:47:18 UTC
  • Revision ID: package-import@ubuntu.com-20111118214718-4ysqm3dhpqwdd7gd
Tags: upstream-0.99~bzr106
ImportĀ upstreamĀ versionĀ 0.99~bzr106

Show diffs side-by-side

added added

removed removed

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