00001 #ifndef rl_MultilayerSurface_h_INCLUDED 00002 #define rl_MultilayerSurface_h_INCLUDED 00003 00004 // File: rl_MultilayerSurface.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_vector.h> // dvm3_Vector 00032 #include <rl_raylib/rl_Multilayer.h> // rl_Multilayer 00033 #include <rl_raylib/rl_Ray.h> // rl_Ray 00034 #include <rl_raylib/rl_ReflectionCoefPOD.h> // rl_ReflectionCoefPOD 00035 00036 class rl_DielectricLayer; // forward declaration 00037 00038 //######################################################################## 00039 // rl_MultilayerSurface 00040 //######################################################################## 00041 // 00051 class rl_MultilayerSurface 00052 { 00053 private: 00054 00056 rl_Multilayer& ml_; 00058 dvm3_Vector& normal_; 00059 00061 rl_ReflectionCoefPOD rflcoef_; 00062 00064 rl_MultilayerSurface(); 00066 rl_MultilayerSurface( rl_MultilayerSurface const& ); 00068 rl_MultilayerSurface& operator=( rl_MultilayerSurface const& ); 00069 00070 public: 00071 00075 virtual ~rl_MultilayerSurface( ); 00076 00084 rl_MultilayerSurface( rl_Multilayer& ml, dvm3_Vector& norm ); 00085 00091 dvm3_Vector const& normal_vector() const; 00092 00100 void set_normal( dvm3_Vector const& norm ); 00101 00102 /* 00103 * Accessor. Find ray intercept with this surface (PLACEHOLDER) 00104 * 00105 * @return distance to the intercept along the ray. 00106 * 00107 * @param ray for which the surface intercept is to be found. 00108 * 00109 * @return 0 if successful. 00110 */ 00111 // int surface_intercept( rl_Ray& ray ); 00112 00122 int reflect( rl_Ray& ray ); 00123 00124 /* 00125 * Mutator. Apply scatter to a ray. (PLACEHOLDER) 00126 * 00127 * @param ray to be scattered. The ray is assumed to be 00128 * already at a valid surface intercept point. The ray 00129 * direction vector and polarization state are updated. 00130 */ 00131 // int scatter( rl_Ray& ray ); 00132 00139 rl_ReflectionCoefPOD const& reflection_coefs() const; 00140 00148 rl_DielectricLayer const& layer( int layer_no ) const; 00149 00158 std::ostream& dump_on( std::ostream& os, int layer_no, 00159 char const pre[] = "", 00160 char const pst[] = "" ) const; 00161 }; 00162 00163 //######################################################################## 00164 //######################################################################## 00165 // 00166 // # # # # # # # ###### #### 00167 // # ## # # # ## # # # 00168 // # # # # # # # # # ##### #### 00169 // # # # # # # # # # # # 00170 // # # ## # # # ## # # # 00171 // # # # ###### # # # ###### #### 00172 // 00173 //######################################################################## 00174 //######################################################################## 00175 00176 //========================================================================= 00177 // dtor; ctors 00178 00179 //------------------------------------------------------------------------- 00180 inline rl_MultilayerSurface:: 00181 rl_MultilayerSurface( rl_Multilayer& ml, dvm3_Vector& norm ) 00182 : ml_( ml ), normal_( norm ) 00183 {} 00184 00185 //========================================================================= 00186 // accessors 00187 00188 //------------------------------------------------------------------------- 00189 inline dvm3_Vector const& rl_MultilayerSurface:: 00190 normal_vector() const 00191 { return normal_; } 00192 00193 //------------------------------------------------------------------------- 00194 inline rl_ReflectionCoefPOD const& rl_MultilayerSurface:: 00195 reflection_coefs() const 00196 { return rflcoef_; } 00197 00198 //========================================================================= 00199 // mutators 00200 00201 //------------------------------------------------------------------------- 00202 inline void rl_MultilayerSurface:: 00203 set_normal( dvm3_Vector const& norm ) 00204 { normal_ = norm; } 00205 00206 // //------------------------------------------------------------------------- 00207 // inline double rl_MultilayerSurface:: 00208 // intercept( rl_Ray& ray ) 00209 // { return 0.0; } 00210 00211 //------------------------------------------------------------------------- 00212 inline int rl_MultilayerSurface:: 00213 reflect( rl_Ray& ray ) 00214 { 00215 int rc = ml_.multilayer_reflect_coef( rflcoef_, ray.energy(), 00216 dot( ray.direction(), normal_ ) ); 00217 if (! rc ) 00218 { 00219 ray.reflect( normal_, rflcoef_ ); 00220 } 00221 return rc; 00222 } 00223 00224 //------------------------------------------------------------------------- 00225 inline rl_DielectricLayer const& rl_MultilayerSurface:: 00226 layer( int layer_no ) const 00227 { return ml_.layer(layer_no); } 00228 00229 //------------------------------------------------------------------------- 00230 inline std::ostream& rl_MultilayerSurface:: 00231 dump_on( std::ostream& os, int layer_no, 00232 char const pre[], 00233 char const pst[] ) const 00234 { 00235 ml_.dump_on( os, layer_no, pre, pst ); 00236 return os; 00237 } 00238 00239 // //------------------------------------------------------------------------- 00240 // inline void rl_MultilayerSurface:: 00241 // scatter( rl_Ray& ray ) 00242 // {} 00243 00244 // rl_MultilayerSurface_h_INCLUDED 00245 #endif