rl_Ray.cc

00001 // File:   rl_Ray.cc
00002 // Author: Terry Gaetz
00003 
00004 // --8<--8<--8<--8<--
00005 //
00006 // Copyright (C) 2006, 2007 Smithsonian Astrophysical Observatory
00007 //
00008 // This file is part of rl_raylib
00009 //
00010 // rl_raylib is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU General Public License
00012 // as published by the Free Software Foundation; either version 2
00013 // of the License, or (at your option) any later version.
00014 //
00015 // rl_raylib is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU General Public License
00021 // along with this program; if not, write to the 
00022 //       Free Software Foundation, Inc. 
00023 //       51 Franklin Street, Fifth Floor
00024 //       Boston, MA  02110-1301, USA
00025 //
00026 // -->8-->8-->8-->8--
00027 
00028 #include <rl_raylib/rl_Ray.h>
00029 #include <iostream>
00030 #include <iomanip>
00031 
00032 using namespace std;
00033 
00034 //=========================================================================
00035 // dtor, ctors, initializers...
00036 
00037 //-------------------------------------------------------------------------
00038 // virtual destructor
00039 
00040 rl_Ray::
00041 ~rl_Ray()
00042 {}
00043 
00044 //=========================================================================
00045 // mutators...
00046 
00047 //-------------------------------------------------------------------------
00048 // reflect this ray's direction vector and polarization state.
00049 
00050 void rl_Ray::
00051 reflect( dvm3_Vector const& normal,
00052          rl_ReflectionCoefPOD const& rflcoef )
00053 {
00054   dvm3_Vector old_dir( dir_ );
00055   reflect_direction_vector( normal );
00056   pol_.reflect( normal, old_dir, dir_, rflcoef );
00057 }
00058 
00059 //-------------------------------------------------------------------------
00060 // translate to to bcs origin; rotate from std to bcs coordinates
00061 
00062 void rl_Ray::
00063 translate_rotate( dvm3_Vector const& trans,
00064                   dvm3_RotMat const& rotmat )
00065 {
00066   rl_BasicRay::translate_rotate( trans, rotmat );
00067   rl_Polarization tmp( pol_ );
00068   tmp.rotate( pol_, rotmat );
00069 }
00070 
00071 //-------------------------------------------------------------------------
00072 // derotate back to std coordinates; detranslate back to std origin
00073 
00074 void rl_Ray::
00075 derotate_detranslate( dvm3_Vector const& trans,
00076                       dvm3_RotMat const& rotmat )
00077 {
00078   rl_BasicRay::derotate_detranslate( trans, rotmat );
00079   rl_Polarization tmp( pol_ );
00080   tmp.derotate( pol_, rotmat );
00081 }
00082 
00083 //-------------------------------------------------------------------------
00084 // write out ray contents with optional pre and post comment strings
00085 std::ostream& rl_Ray::
00086 print_on( std::ostream&   os,          //i  output stream
00087           char const      pre[],       //i  optional prefix comment
00088           char const      pst[]        //i  optional postfix comment
00089         ) const
00090 {
00091   if ( ::strlen(pre) ) { os << pre; }
00092   os.setf(ios::showpoint);
00093   os.setf(ios::fixed);
00094   os << setw(8) << id_ << " : ";
00095   os << " " << setw(18) << energy_ << " : (";
00096   pos_.print_on( os );
00097   os << ") (" << setw(18);
00098   dir_.print_on( os );
00099   os << ")";
00100   if ( ::strlen(pst) ) { os << pst; }
00101   os << endl;
00102 
00103   if ( ::strlen(pre) ) { os << pre; }
00104   os << setw(8) << id_ << " : ";
00105   pol_.print_on( os );
00106   if ( ::strlen(pst) ) { os << pst; }
00107   os << endl;
00108 
00109   return os;
00110 }

Generated on Mon Nov 3 18:15:05 2008 for rl_raylib by  doxygen 1.5.6