Rayr.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *                                                                       *
00003  * Open Physics Abstraction Layer                                        *
00004  * Copyright (C) 2004-2005                                               *
00005  * Alan Fischer  alan.fischer@gmail.com                                  *
00006  * Andres Reinot  andres@reinot.com                                      *
00007  * Tyler Streeter  tylerstreeter@gmail.com                               *
00008  * All rights reserved.                                                  *
00009  * Web: opal.sourceforge.net                                             *
00010  *                                                                       *
00011  * This library is free software; you can redistribute it and/or         *
00012  * modify it under the terms of EITHER:                                  *
00013  *   (1) The GNU Lesser General Public License as published by the Free  *
00014  *       Software Foundation; either version 2.1 of the License, or (at  *
00015  *       your option) any later version. The text of the GNU Lesser      *
00016  *       General Public License is included with this library in the     *
00017  *       file license-LGPL.txt.                                          *
00018  *   (2) The BSD-style license that is included with this library in     *
00019  *       the file license-BSD.txt.                                       *
00020  *                                                                       *
00021  * This library is distributed in the hope that it will be useful,       *
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024  * license-LGPL.txt and license-BSD.txt for more details.                *
00025  *                                                                       *
00026  *************************************************************************/
00027 
00028 #ifndef OPAL_RAYR_H
00029 #define OPAL_RAYR_H
00030 
00031 #include "OpalMath.h"
00032 
00033 namespace opal
00034 {
00035         class Rayr;
00036 
00038         inline std::ostream& operator<<(std::ostream& o, const Rayr& r);
00039 
00040         class Rayr
00041         {
00042         private:
00043                 Vec3r mDir;
00044                 Point3r mOrigin;
00045 
00046         public:
00047                 Rayr()
00048                 {
00049                         mDir.set(0,0,1);
00050                         mOrigin.set(0,0,0);
00051                 }
00052 
00053                 Rayr(const opal::Point3r & origin, const opal::Vec3r & dir)
00054                 {
00055                         mDir = dir;
00056                         mOrigin = origin;
00057                 }
00058 
00059                 //Rayr(const opal::Vec3r & dir, const opal::Point3r & origin)
00060                 //{
00061                 //      mDir = dir;
00062                 //      mOrigin = origin;
00063                 //}
00064 
00065                 void set(const opal::Point3r & origin, const opal::Vec3r & dir)
00066                 {
00067                         mDir = dir;
00068                         mOrigin = origin;
00069                 }
00070 
00071                 //void set(const opal::Vec3r & dir, const opal::Point3r & origin)
00072                 //{
00073                 //      mDir = dir;
00074                 //      mOrigin = origin;
00075                 //}
00076 
00077                 Vec3r getDir()const
00078                 {
00079                         return mDir;
00080                 }
00081 
00082                 Point3r getOrigin()const
00083                 {
00084                         return mOrigin;
00085                 }
00086 
00087                 real getLength()const
00088                 {
00089                         return mDir.length();
00090                 }
00091 
00092                 void setOrigin( const Point3r & p )
00093                 {
00094                         mOrigin = p;
00095                 }
00096 
00097                 void setDir( const Vec3r & d )
00098                 {
00099                         mDir = d;
00100                 }
00101 
00102                 Rayr(const Rayr & src)
00103                 {
00104                         mDir = src.mDir;
00105                         mOrigin = src.mOrigin;
00106                 }
00107         };
00108 
00109         inline std::ostream& operator<<(std::ostream& o, const Rayr& r)
00110         {
00111                 Point3r origin = r.getOrigin();
00112                 Vec3r dir = r.getDir();
00113                 return o << "Origin: [" << origin[0] << " " << origin[1] << " " 
00114                         << origin[2] << "] Direction: [" << dir[0] << " " << dir[1] 
00115                         << " " << dir[2] << "]";
00116         }
00117 }
00118 
00119 #endif
00120 

Generated on Tue May 16 17:49:52 2006 for OPAL by  doxygen 1.4.6-NO