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

Ray.cxx

Go to the documentation of this file.
00001 // $Id: Ray.cxx,v 1.3 2001/10/06 14:18:51 burnett Exp $
00002 
00003 #include "geometry/Ray.h"
00004 
00005 Ray::Ray( const Point& p, const Vector& d )
00006 : pos( p ), dir(d.unit()) , arclength(0), flag(0)
00007 {
00008 }
00009 
00010 Ray::Ray( const Ray& r )
00011 :pos(r.pos),GeomObject(), dir(r.dir), arclength(r.arclength)
00012 {  // copy constructor
00013 }
00014 
00015 
00016 Point
00017 Ray::position(double s) const
00018 {
00019 //   return  pos + (s * dir);
00020   Point p = pos;
00021   return p + s*dir;
00022 }
00023 //should define operators to do this
00024 
00025 
00026 void
00027 Ray::printOn( std::ostream& os ) const
00028 {  // printing function using C++ ostream class
00029         os << "Ray: origin = " << pos << ", direction = "
00030            << dir << "\n";
00031 }
00032 
00033 GeomObject&
00034 Ray::transform( const CoordTransform & T)
00035 {
00036   pos.transform(T);
00037   dir.transform(T);
00038   return *this;
00039 }
00040 
00041 double
00042 Ray::distanceOfClosestApproach( const Ray& r ) const
00043 {
00044    Vector perp = direction(0.).cross(r.direction(0.));
00045    double d = (perp*(r.position(0.)-pos)) / perp.mag();
00046    return d;
00047 }
00048 
00049 Vector
00050 Ray::vectorOfClosestApproach( const Ray& r ) const
00051 {
00052    Vector perp = direction(0.).cross(r.direction(0.));
00053    double d = (perp*(r.position(0.)-pos)) / perp.mag();
00054    return d*perp;
00055 }
00056 
00057 
00058 

Generated at Wed Nov 21 12:20:12 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000