Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Plane.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/geometry/src/Plane.cxx,v 1.2 1999/12/21 04:37:19 burnett Exp $
00002 //
00003 
00004 
00005 #include "geometry/Plane.h"
00006 #include <cfloat>
00007 
00008 
00009 Plane::Plane(const Point& o, const Vector& n)
00010 : Surface(o, n.unit())   // save unit vector in Surface
00011 , m_d(n.magnitude())             // magnitude here
00012 {
00013    if(m_d==0)
00014    FATAL("Plane constructor called with null unit vector");
00015 
00016 }
00017 Plane::Plane(const Point& o, const Vector& n, double dist)
00018 : Surface(o, n.unit())   // save unit vector in Surface
00019 , m_d(dist)
00020 {}
00021 
00022 
00023 double
00024 Plane::distance( const Point& x, const Vector& vhat, int inout)const
00025 {
00026   // distance along direction v from point x to enter or leave the surface.
00027    double denom = vhat*direction();
00028    return ( denom*inout<=0 )? FLT_MAX : how_near(x)/denom;
00029 }
00030 
00031 void
00032 Plane::reverse()
00033 {
00034     Surface::reverse();
00035     m_d *=-1.;
00036 }
00037 
00038 Vector Plane::normal(const Point& ) const
00039 {
00040     return Surface::direction();
00041 }
00042 
00043 Surface&
00044 Plane::copy()const
00045 {
00046     return *new Plane(origin(), direction(), m_d);
00047 }
00048 void
00049 Plane::printOn( std::ostream& os ) const
00050 {       os << "Plane: origin= " << origin()
00051        << ",\t normal= " << direction()
00052            << ",\t distance= " << m_d
00053        << "\n";
00054 }
00055 
00056 
00057 
00058 
00059 

Generated at Mon Nov 26 18:18:21 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000