rl_Polarization.h

00001 #ifndef rl_Polarization_h_INCLUDED
00002 #define rl_Polarization_h_INCLUDED
00003 
00004 // File:   rl_Polarization.h
00005 // Author: Terry Gaetz
00006 
00007 /* --8<--8<--8<--8<--
00008  *
00009  * Copyright (C) 2006, 2007 Smithsonian Astrophysical Observatory
00010  *
00011  * This file is part of rl_raylib
00012  *
00013  * rl_raylib 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_raylib 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 #include <dvm3/dvm3.h>                      // dvm3_Vector dvm3_RotMat
00032 #include <rl_raylib/rl_Traits.h>            // rl_Traits::complex
00033 
00034 class rl_ReflectionCoefPOD;                 // forward declaration
00035 
00036 #include <cstdio>  
00037 
00038 //########################################################################
00039 //
00040 // rl_PolCSPOD
00041 //
00042 // A class to encapuslate OSAC-style polarization amplitudes.
00043 //
00044 // Relation to OSAC polarization amplitudes:
00045 //
00046 //      c2_.q1 <--> c2comp(1),   c2_.q2 <--> c2comp(2),
00047 //      s2_.q1 <--> s2comp(1),   s2_.q2 <--> s2comp(2)
00048 //
00049 //   random polarization:
00050 //       wt =   c2_.q1.r^2 + c2_.q2.r^2 + c2_.q1.i^2 + c2_.q2.i^2
00051 //            + s2_.q1.r^2 + s2_.q2.r^2 + s2_.q1.i^2 + s2_.q2.i^2
00052 //
00053 //       wt =   |c2[0]|^2 + |s2[0]|^2 + |c2[1]|^2 + |s2[1]|^2
00054 //
00055 //   discrete polarization:
00056 //       wt =   c2_.q1.r^2 + c2_.q2.r^2 + c2_.q1.i^2 + c2_.q2.i^2
00057 //            + s2_.q1.r^2 + s2_.q2.r^2 + s2_.q1.i^2 + s2_.q2.i^2
00058 //            * 2.0 * (c2_.q1.i s2_.q1.r + c2_.q2.i s2_.q2.r
00059 //                   - c2_.q1.r s2_.q1.i - c2_.q2.r s2_.q2.i)
00060 //
00061 //       wt =   |c2[0]|^2 + |s2[0]|^2 + |c2[1]|^2 + |s2[1]|^2
00062 //            + 2 ( c2[0] s2[0]^* + c2[1] s2[1]^* )
00063 //
00064 //########################################################################
00065 
00106 struct rl_PolCSPOD
00107 {
00109   rl_Traits::complex c2_[2];  
00111   rl_Traits::complex s2_[2];  
00112 
00120   void init( double b_over_a = 1.0,
00121              double psi      = 0.0
00122            );
00123 
00130   void   attenuate( double factor );
00131 
00137   double intensity() const;
00138 
00145   std::ostream& print_on( std::ostream& os ) const;
00146 
00153   void cprint_on( FILE* of ) const;
00154 };
00155 
00163 inline std::ostream&
00164 operator<<( std::ostream& os, rl_PolCSPOD const& polcs )
00165   //  The state is written as "[(r,i)(r,i)][(r,i)(r,i)]".
00166 {
00167   return polcs.print_on( os );
00168 }
00169 
00170 //########################################################################
00171 // rl_Polarization
00172 //########################################################################
00173 //
00186 class rl_Polarization
00187 {
00188 public:
00189 
00191   typedef rl_Traits::complex complex;
00192 
00193 private:
00194 
00196   dvm3_Vector C_r_;
00198   dvm3_Vector C_i_;
00200   dvm3_Vector S_r_;
00202   dvm3_Vector S_i_;
00203 
00205   rl_Polarization& operator=( rl_Polarization const& );
00206 
00207 public:
00208 
00212  ~rl_Polarization();
00213 
00217   rl_Polarization();
00218 
00224   rl_Polarization( rl_Polarization const& rhs );
00225 
00233   rl_Polarization( rl_PolCSPOD const& cs, dvm3_Vector const& dir );
00234 
00241   void init( rl_PolCSPOD const& cs, dvm3_Vector const& dir );
00242 
00249   void get_PolCSPOD( rl_PolCSPOD& cs, dvm3_Vector const& dir ) const;
00250 
00256   double intensity() const;
00257 
00265   void rotate(   rl_Polarization& rotated,   dvm3_RotMat const& rot_mtx );
00266 
00274   void derotate( rl_Polarization& derotated, dvm3_RotMat const& rot_mtx );
00275 
00281   void attenuate( double factor );
00282 
00294   void reflect( 
00295                 dvm3_Vector          const& normal, 
00296                 dvm3_Vector          const& dir_in,
00297                 dvm3_Vector          const& dir_out,
00298                 rl_ReflectionCoefPOD const& rflcoef 
00299               );
00300 
00302   dvm3_Vector const& C_r() const;
00304   dvm3_Vector const& C_i() const;
00306   dvm3_Vector const& S_r() const;
00308   dvm3_Vector const& S_i() const;
00309 
00316   std::ostream& print_on( std::ostream& os ) const;
00317 
00324   void cprint_on( std::FILE* of ) const;
00325 };
00326   
00327 //########################################################################
00328 //########################################################################
00329 //
00330 //    #    #    #  #          #    #    #  ######   ####
00331 //    #    ##   #  #          #    ##   #  #       #
00332 //    #    # #  #  #          #    # #  #  #####    ####
00333 //    #    #  # #  #          #    #  # #  #            #
00334 //    #    #   ##  #          #    #   ##  #       #    #
00335 //    #    #    #  ######     #    #    #  ######   ####
00336 //
00337 //########################################################################
00338 //########################################################################
00339 
00340 //-------------------------------------------------------------------------
00341 inline
00342 rl_Polarization::
00343 ~rl_Polarization()
00344 {}
00345 
00346 //-------------------------------------------------------------------------
00347 inline
00348 rl_Polarization::
00349 rl_Polarization()
00350 {}
00351 
00352 //-------------------------------------------------------------------------
00353 inline rl_Polarization::
00354 rl_Polarization( rl_PolCSPOD const& cs, dvm3_Vector const& dir )
00355 { init( cs, dir ); }
00356 
00357 //-------------------------------------------------------------------------
00358 inline rl_Polarization::
00359 rl_Polarization( rl_Polarization const& rhs )
00360   : C_r_( rhs.C_r_ ),
00361     C_i_( rhs.C_i_ ),
00362     S_r_( rhs.S_r_ ),
00363     S_i_( rhs.S_i_ ) 
00364 {}
00365 
00366 //-------------------------------------------------------------------------
00367 inline void rl_Polarization::
00368 rotate( rl_Polarization& rotated, dvm3_RotMat const& rot_mtx )
00369 {
00370   rot_mtx.mvmult( rotated.C_r_, C_r_ );
00371   rot_mtx.mvmult( rotated.C_i_, C_i_ );
00372   rot_mtx.mvmult( rotated.S_r_, S_r_ );
00373   rot_mtx.mvmult( rotated.S_i_, S_i_ );
00374 }
00375 
00376 //-------------------------------------------------------------------------
00377 inline void rl_Polarization::
00378 derotate( rl_Polarization& derotated, dvm3_RotMat const& rot_mtx )
00379 {
00380   rot_mtx.mtvmult( derotated.C_r_, C_r_ );
00381   rot_mtx.mtvmult( derotated.C_i_, C_i_ );
00382   rot_mtx.mtvmult( derotated.S_r_, S_r_ );
00383   rot_mtx.mtvmult( derotated.S_i_, S_i_ );
00384 }
00385 
00386 //-------------------------------------------------------------------------
00387 inline dvm3_Vector const& rl_Polarization::
00388 C_r() const
00389 { 
00390   return C_r_;
00391 }
00392 
00393 //-------------------------------------------------------------------------
00394 inline dvm3_Vector const& rl_Polarization::
00395 C_i() const
00396 { 
00397   return C_i_;
00398 }
00399 
00400 //-------------------------------------------------------------------------
00401 inline dvm3_Vector const& rl_Polarization::
00402 S_r() const
00403 { 
00404   return S_r_;
00405 }
00406 
00407 //-------------------------------------------------------------------------
00408 inline dvm3_Vector const& rl_Polarization::
00409 S_i() const
00410 { 
00411   return S_i_;
00412 }
00413 
00414 //-------------------------------------------------------------------------
00422 inline std::ostream&
00423 operator<<( std::ostream& os, rl_Polarization const& polvec )
00424 {
00425   return polvec.print_on( os );
00426 }
00427 
00428 // rl_Polarization_h_INCLUDED
00429 #endif

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