rl_RayMath.h

00001 #ifndef rl_RayMath_h_INCLUDED
00002 #define rl_RayMath_h_INCLUDED
00003 
00004 // File:   rl_RayMath.h
00005 // Author: Terry Gaetz
00006 
00007 /* --8<--8<--8<--8<--
00008  *
00009  * Copyright (C) 2006 Smithsonian Astrophysical Observatory
00010  *
00011  * This file is part of rl_ray
00012  *
00013  * rl_ray is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU General Public License
00015  * as published by the Free Software Foundation; either version 2
00016  * of the License, or (at your option) any later version.
00017  *
00018  * rl_ray is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the 
00025  *       Free Software Foundation, Inc. 
00026  *       51 Franklin Street, Fifth Floor
00027  *       Boston, MA  02110-1301, USA
00028  *
00029  * -->8-->8-->8-->8-- */
00030 
00031 /****************************************************************************
00032  * Description: collection of methods for rl_RayMath
00033  *
00034  * History
00035  *--------
00036  * 1.0.1 2004-Dec-07  tjg  simplify/remove include guards
00037  * 0.0.0 1998-Jan-30  tjg  original version
00038  */
00039 
00040 #include <dvm3/dvm3_rotmat.h>                   // dvm3_RotMat
00041 
00042 //########################################################################
00043 // rl_RayMath
00044 //########################################################################
00091 class rl_RayMath
00092 {
00093 public:
00094 
00101   inline static void rotate( dvm3_RotMat const& rotmat,
00102                              dvm3_Vector&       vector );
00103 
00110   inline static void rotate( dvm3_RotMat const& rotmat,
00111                              double             vector[] );
00112 
00120   inline static void derotate( dvm3_RotMat const& rotmat,
00121                                dvm3_Vector&       vector );
00122 
00130   inline static void derotate( dvm3_RotMat const& rotmat,
00131                                double             vector[] );
00132 
00140   inline static void translate_rotate( dvm3_Vector const& trans,
00141                                        dvm3_RotMat const& rotmat,
00142                                        dvm3_Vector&       vector );
00143 
00151   inline static void translate_rotate( double      const  trans[],
00152                                        dvm3_RotMat const& rotmat,
00153                                        double             vector[] );
00154 
00163   inline static void derotate_detranslate( dvm3_Vector const& trans, 
00164                                            dvm3_RotMat const& rotmat,
00165                                            dvm3_Vector&       vector );
00174   inline static void derotate_detranslate( double      const  trans[],
00175                                            dvm3_RotMat const& rotmat,
00176                                            double             vector[] );
00177 };
00178 
00179 //########################################################################
00180 //########################################################################
00181 //
00182 //    #    #    #  #          #    #    #  ######   ####
00183 //    #    ##   #  #          #    ##   #  #       #
00184 //    #    # #  #  #          #    # #  #  #####    ####
00185 //    #    #  # #  #          #    #  # #  #            #
00186 //    #    #   ##  #          #    #   ##  #       #    #
00187 //    #    #    #  ######     #    #    #  ######   ####
00188 //
00189 //########################################################################
00190 //########################################################################
00191 
00192 //=========================================================================
00193 // rotate from STD to BCS coordinates
00194 
00195 //-------------------------------------------------------------------------
00196 inline void rl_RayMath::
00197 rotate( dvm3_RotMat const& rotmat,
00198         dvm3_Vector&       vector )
00199 {
00200   dvm3_Vector tmp( vector );
00201   rotmat.mvmult( vector, tmp );
00202 }
00203 
00204 //-------------------------------------------------------------------------
00205 inline void rl_RayMath::
00206 rotate( dvm3_RotMat const& rotmat,
00207         double             vector[] )
00208 {
00209   double tmp[3];  
00210   vm_V3Math<double>::copy(tmp, vector); 
00211   rotmat.mvmult( vector, tmp );
00212 }
00213 
00214 //=========================================================================
00215 // derotate from BCS back to STD coordinates
00216 
00217 //-------------------------------------------------------------------------
00218 inline void rl_RayMath::
00219 derotate( dvm3_RotMat const& rotmat,
00220           dvm3_Vector&       vector )
00221 {
00222   dvm3_Vector tmp( vector );
00223   rotmat.mtvmult( vector, tmp );
00224 }
00225 
00226 //-------------------------------------------------------------------------
00227 inline void rl_RayMath::
00228 derotate( dvm3_RotMat const& rotmat,
00229           double             vector[] )
00230 {
00231   double tmp[3]; 
00232   vm_V3Math<double>::copy(tmp, vector);
00233   rotmat.mtvmult( vector, tmp );
00234 }
00235 
00236 //=========================================================================
00237 // translate to to BCS origin; rotate from STD to BCS coordinates
00238 
00239 //-------------------------------------------------------------------------
00240 inline void rl_RayMath::
00241 translate_rotate( dvm3_Vector const& trans,
00242                   dvm3_RotMat const& rotmat,
00243                   dvm3_Vector&       vector )
00244 {
00245   vector += trans;
00246   dvm3_Vector tmp( vector );
00247   rotmat.mvmult( vector, tmp );
00248 }
00249 
00250 //-------------------------------------------------------------------------
00251 inline void rl_RayMath::
00252 translate_rotate( double      const  trans[],
00253                   dvm3_RotMat const& rotmat,
00254                   double             vector[] )
00255 {
00256   vm_V3Math<double>::add_eq( vector, trans );
00257   double tmp[3];
00258   vm_V3Math<double>::copy(tmp, vector);
00259   rotmat.mvmult( vector, tmp );
00260 }
00261 
00262 //=========================================================================
00263 // derotate from BCS back to STD coordinates; detranslate back to STD origin
00264 
00265 //-------------------------------------------------------------------------
00266 inline void rl_RayMath::
00267 derotate_detranslate( dvm3_Vector const& trans,
00268                       dvm3_RotMat const& rotmat,
00269                       dvm3_Vector&       vector )
00270 {
00271   dvm3_Vector tmp( vector );
00272   rotmat.mtvmult( vector, tmp );
00273   vector -= trans;
00274 }
00275 
00276 //-------------------------------------------------------------------------
00277 inline void rl_RayMath::
00278 derotate_detranslate( double      const  trans[],
00279                       dvm3_RotMat const& rotmat,
00280                       double             vector[] )
00281 {
00282   double tmp[3];
00283   vm_V3Math<double>::copy(tmp, vector);
00284   rotmat.mtvmult( vector, tmp );
00285   vm_V3Math<double>::sub_eq( vector, trans );
00286 }
00287 
00288 // rl_RayMath.h
00289 #endif

Generated on Fri Jun 27 15:52:40 2008 for rl_basicray by  doxygen 1.5.1