rl_TransmissionCoefPOD.h

00001 #ifndef rl_TransmissionCoefPOD_h_INCLUDED
00002 #define rl_TransmissionCoefPOD_h_INCLUDED
00003 
00004 // File:   rl_transmissioncoefpod.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 /****************************************************************************
00032  * Description: declare rl_TransmissionCoefPOD
00033  *
00034  * rl_TransmissionCoeff contains the in-plane and out-of-plane reflection
00035  * coefficients;
00036  *   PolPlus:    '+', or parallel      (in-plane),     reflection coefficient
00037  *   PolMinus:   '-', or perpendicular (out-of-plane), reflection coefficient
00038  *
00039  * Here, in-plane means the E-vector is in the vector in the plane 
00040  * of incidence (defined by the ray direction and the surface normal),
00041  * while out-of-plane means the E-vector is perpendicular to the 
00042  * plane of incidence.
00043  *
00044  * NOTE:  a POD class must satisfy (Jack W. Reeves, C++Report, February 1998,
00045  *         p. 46-54):
00046  *  - no user-declared constructors, copy-assign operator, or destructor
00047  *  - no private or protected nonstatic data members
00048  *  - no base classes
00049  *  - no virtual functions
00050  *  - no nonstatic data members of type pointer to member,
00051  *       non-POD-struct/class (or array of such types) or reference
00052  *
00053  * History
00054  *--------
00055  * 1.0.1 2004-Dec-07  tjg  simplify/remove include guards
00056  * 0.2.0 1998-Jun-24  tjg  C++ version
00057  * 0.1.0 1998-Jun-23  tjg  revised notation; renamed file
00058  * 0.0.0 1995-May-18  tjg  original version
00059  */
00060 
00061 #include <rl_raylib/rl_Traits.h>
00062 #include <cstring>                  // strlen
00063 #include <iostream>                 // <<
00064 
00065 //########################################################################
00066 // rl_TransmissionCoefPOD
00067 //########################################################################
00068 //
00075 class rl_TransmissionCoefPOD
00076 {
00077 private:
00078 
00080   rl_Traits::complex para_;  
00082   rl_Traits::complex perp_;
00083 
00084 public:
00085 
00090   void init();
00091 
00092     
00099   void init( rl_Traits::complex& para,
00100              rl_Traits::complex& perp );
00101 
00127   double transmission( double polarization_factor = 0.0 ) const;
00128 
00132   rl_Traits::complex para() const;
00133 
00137   rl_Traits::complex& para();
00138 
00142   rl_Traits::complex perp() const;
00143 
00147   rl_Traits::complex& perp();
00148 
00156   std::ostream& print_on( std::ostream& os, char const pre[] = "",
00157                                             char const pst[] = "" ) const;
00158 
00166   void cprint_on( std::FILE* of, char const pre[] = "",
00167                                  char const pst[] = "" ) const;
00168 };
00169 
00170 inline void rl_TransmissionCoefPOD::
00171 init()
00172 {
00173   para_ = rl_Traits::complex();
00174   perp_ = rl_Traits::complex();
00175 }
00176 
00177 inline void rl_TransmissionCoefPOD::
00178 init( rl_Traits::complex& para,
00179       rl_Traits::complex& perp )
00180 {
00181   para_ = para;
00182   perp_ = perp;
00183 }
00184 
00185 inline rl_Traits::complex rl_TransmissionCoefPOD::
00186 para() const
00187 { return para_; }
00188 
00189 inline rl_Traits::complex rl_TransmissionCoefPOD::
00190 perp() const
00191 { return perp_; }
00192 
00193 inline rl_Traits::complex& rl_TransmissionCoefPOD::
00194 para()
00195 { return para_; }
00196 
00197 inline rl_Traits::complex& rl_TransmissionCoefPOD::
00198 perp()
00199 { return perp_; }
00200 
00201 inline double rl_TransmissionCoefPOD::
00202 transmission( double polarization_factor ) const
00203 {
00204   return ( norm( perp_ ) * (1.0 + polarization_factor ) 
00205          + norm( para_ ) * (1.0 - polarization_factor ) ) / 2.0;
00206 }
00207 
00208 inline std::ostream& rl_TransmissionCoefPOD::
00209 print_on( std::ostream& os, char const pre[], char const pst[] ) const
00210 {
00211   if ( std::strlen(pre) ) { os << pre; }
00212   os << "[" << para_ << "][" << perp_ << "]";
00213   if ( std::strlen(pst) ) { os << pst; }
00214   return os;
00215 }
00216 
00217 inline void rl_TransmissionCoefPOD::
00218 cprint_on( std::FILE* of, char const pre[], char const pst[] ) const
00219 {
00220   if ( std::strlen(pre) ) { std::fprintf(of, "%s", pre); }
00221   std::fprintf(of, "[%.15e, %.15e] [%.15e, %.15e]\n",
00222      para_.real(), para_.imag(), perp_.real(), perp_.imag());
00223   if ( std::strlen(pst) ) { std::fprintf(of, "%s", pst); }
00224 }
00225 
00226 inline std::ostream&
00227 operator<<( std::ostream& os, rl_TransmissionCoefPOD const& rfl )
00228 { rfl.print_on( os ); return os; }
00229 
00230 // rl_TransmissionCoefPOD_h_INCLUDED
00231 #endif

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