rl_ReflectionCoefPOD.h
00001 #ifndef rl_ReflectionCoefPOD_h_INCLUDED
00002 #define rl_ReflectionCoefPOD_h_INCLUDED
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include <rl_raylib/rl_Traits.h>
00062 #include <cstring>
00063 #include <cstdio>
00064 #include <iostream>
00065
00066
00067
00068
00069
00076 class rl_ReflectionCoefPOD
00077 {
00078 private:
00079
00081 rl_Traits::complex para_;
00083 rl_Traits::complex perp_;
00084
00085 public:
00086
00112 double reflectivity( double polarization_factor = 0.0 ) const;
00113
00118 void init();
00119
00127 void init( rl_Traits::complex& para,
00128 rl_Traits::complex& perp );
00129
00133 rl_Traits::complex para() const;
00134
00138 rl_Traits::complex& para();
00139
00143 rl_Traits::complex perp() const;
00144
00148 rl_Traits::complex& perp();
00149
00157 std::ostream& print_on( std::ostream& os, char const pre[] = "",
00158 char const pst[] = "" ) const;
00159
00167 void cprint_on( std::FILE* of, char const pre[] = "",
00168 char const pst[] = "" ) const;
00169 };
00170
00171 inline void rl_ReflectionCoefPOD::
00172 init()
00173 {
00174 para_ = rl_Traits::complex();
00175 perp_ = rl_Traits::complex();
00176 }
00177
00178 inline void rl_ReflectionCoefPOD::
00179 init( rl_Traits::complex& para,
00180 rl_Traits::complex& perp )
00181 {
00182 para_ = para;
00183 perp_ = perp;
00184 }
00185
00186 inline rl_Traits::complex rl_ReflectionCoefPOD::
00187 para() const
00188 { return para_; }
00189
00190 inline rl_Traits::complex rl_ReflectionCoefPOD::
00191 perp() const
00192 { return perp_; }
00193
00194 inline rl_Traits::complex& rl_ReflectionCoefPOD::
00195 para()
00196 { return para_; }
00197
00198 inline rl_Traits::complex& rl_ReflectionCoefPOD::
00199 perp()
00200 { return perp_; }
00201
00202 inline double rl_ReflectionCoefPOD::
00203 reflectivity( double polarization_factor ) const
00204 {
00205 return ( norm( perp_ ) * (1.0 + polarization_factor )
00206 + norm( para_ ) * (1.0 - polarization_factor ) ) / 2.0;
00207 }
00208
00209 inline std::ostream& rl_ReflectionCoefPOD::
00210 print_on( std::ostream& os, char const pre[], char const pst[] ) const
00211 {
00212 if ( std::strlen(pre) ) { os << pre; }
00213 os << "[" << para_ << "][" << perp_ << "]";
00214 if ( std::strlen(pst) ) { os << pst; }
00215 return os;
00216 }
00217
00218 inline void rl_ReflectionCoefPOD::
00219 cprint_on( std::FILE* of, char const pre[], char const pst[] ) const
00220 {
00221 if ( std::strlen(pre) ) { std::fprintf(of, "%s", pre); }
00222 std::fprintf(of, "[%.15e, %.15e] [%.15e, %.15e]\n",
00223 para().real(), para().imag(), perp().real(), perp().imag());
00224 if ( std::strlen(pst) ) { std::fprintf(of, "%s", pst); }
00225 }
00226
00227 inline std::ostream&
00228 operator<<( std::ostream& os, rl_ReflectionCoefPOD const& rfl )
00229 { rfl.print_on( os ); return os; }
00230
00231
00232 #endif