rl_raylib  1.1.10
rl_MultilayerSurface.h
1 #ifndef rl_MultilayerSurface_h_INCLUDED
2 #define rl_MultilayerSurface_h_INCLUDED
3 
4 // File: rl_MultilayerSurface.h
5 // Author: Terry Gaetz
6 
7 /* --8<--8<--8<--8<--
8  *
9  * Copyright (C) 2006, 2007 Smithsonian Astrophysical Observatory
10  *
11  * This file is part of rl_raylib
12  *
13  * rl_raylib is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * rl_raylib is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the
25  * Free Software Foundation, Inc.
26  * 51 Franklin Street, Fifth Floor
27  * Boston, MA 02110-1301, USA
28  *
29  * -->8-->8-->8-->8-- */
30 
31 #include <dvm3/dvm3_vector.h> // dvm3_Vector
32 #include <rl_raylib/rl_Multilayer.h> // rl_Multilayer
33 #include <rl_raylib/rl_Ray.h> // rl_Ray
34 #include <rl_raylib/rl_ReflectionCoefPOD.h> // rl_ReflectionCoefPOD
35 
36 class rl_DielectricLayer; // forward declaration
37 
38 //########################################################################
39 // rl_MultilayerSurface
40 //########################################################################
41 //
52 {
53 private:
54 
56  rl_Multilayer& ml_;
58  dvm3_Vector& normal_;
59 
61  rl_ReflectionCoefPOD rflcoef_;
62 
68  rl_MultilayerSurface& operator=( rl_MultilayerSurface const& );
69 
70 public:
71 
75  virtual ~rl_MultilayerSurface( );
76 
84  rl_MultilayerSurface( rl_Multilayer& ml, dvm3_Vector& norm );
85 
91  dvm3_Vector const& normal_vector() const;
92 
100  void set_normal( dvm3_Vector const& norm );
101 
102  /*
103  * Accessor. Find ray intercept with this surface (PLACEHOLDER)
104  *
105  * @return distance to the intercept along the ray.
106  *
107  * @param ray for which the surface intercept is to be found.
108  *
109  * @return 0 if successful.
110  */
111  // int surface_intercept( rl_Ray& ray );
112 
122  int reflect( rl_Ray& ray );
123 
124  /*
125  * Mutator. Apply scatter to a ray. (PLACEHOLDER)
126  *
127  * @param ray to be scattered. The ray is assumed to be
128  * already at a valid surface intercept point. The ray
129  * direction vector and polarization state are updated.
130  */
131  // int scatter( rl_Ray& ray );
132 
139  rl_ReflectionCoefPOD const& reflection_coefs() const;
140 
148  rl_DielectricLayer const& layer( int layer_no ) const;
149 
158  std::ostream& dump_on( std::ostream& os, int layer_no,
159  char const pre[] = "",
160  char const pst[] = "" ) const;
161 };
162 
163 //########################################################################
164 //########################################################################
165 //
166 // # # # # # # # ###### ####
167 // # ## # # # ## # # #
168 // # # # # # # # # # ##### ####
169 // # # # # # # # # # # #
170 // # # ## # # # ## # # #
171 // # # # ###### # # # ###### ####
172 //
173 //########################################################################
174 //########################################################################
175 
176 //=========================================================================
177 // dtor; ctors
178 
179 //-------------------------------------------------------------------------
180 inline rl_MultilayerSurface::
181 rl_MultilayerSurface( rl_Multilayer& ml, dvm3_Vector& norm )
182  : ml_( ml ), normal_( norm )
183 {}
184 
185 //=========================================================================
186 // accessors
187 
188 //-------------------------------------------------------------------------
189 inline dvm3_Vector const& rl_MultilayerSurface::
191 { return normal_; }
192 
193 //-------------------------------------------------------------------------
196 { return rflcoef_; }
197 
198 //=========================================================================
199 // mutators
200 
201 //-------------------------------------------------------------------------
202 inline void rl_MultilayerSurface::
203 set_normal( dvm3_Vector const& norm )
204 { normal_ = norm; }
205 
206 // //-------------------------------------------------------------------------
207 // inline double rl_MultilayerSurface::
208 // intercept( rl_Ray& ray )
209 // { return 0.0; }
210 
211 //-------------------------------------------------------------------------
212 inline int rl_MultilayerSurface::
214 {
215  int rc = ml_.multilayer_reflect_coef( rflcoef_, ray.energy(),
216  dot( ray.direction(), normal_ ) );
217  if (! rc )
218  {
219  ray.reflect( normal_, rflcoef_ );
220  }
221  return rc;
222 }
223 
224 //-------------------------------------------------------------------------
226 layer( int layer_no ) const
227 { return ml_.layer(layer_no); }
228 
229 //-------------------------------------------------------------------------
230 inline std::ostream& rl_MultilayerSurface::
231 dump_on( std::ostream& os, int layer_no,
232  char const pre[],
233  char const pst[] ) const
234 {
235  ml_.dump_on( os, layer_no, pre, pst );
236  return os;
237 }
238 
239 // //-------------------------------------------------------------------------
240 // inline void rl_MultilayerSurface::
241 // scatter( rl_Ray& ray )
242 // {}
243 
244 // rl_MultilayerSurface_h_INCLUDED
245 #endif
std::ostream & dump_on(std::ostream &os, int layer_no, char const pre[]="", char const pst[]="") const
Dump information about a layer.
std::ostream & dump_on(std::ostream &os, int layer_no, char const pre[]="", char const pst[]="") const
Dump information about layer layer_no to stream os.
A class encapsulating a multilayer surface, including surface normal.
An rl_BasicRay with added polarization information.
Definition: rl_Ray.h:45
int reflect(rl_Ray &ray)
Mutator.
void reflect(dvm3_Vector const &normal, rl_ReflectionCoefPOD const &rflcoef)
Reflect this ray's direction vector and polarization state.
Definition: rl_Ray.cc:51
A Plain Ol' Data class representing complex reflection coefficients.
rl_ReflectionCoefPOD const & reflection_coefs() const
Accessor.
dvm3_Vector const & normal_vector() const
Accessor.
rl_DielectricLayer const & layer(int layer_no) const
Accessor.
void set_normal(dvm3_Vector const &norm)
Mutator.
int multilayer_reflect_coef(rl_ReflectionCoefPOD &rfl, double energy, double sg)
Evaluate the multilayer reflection coefficients.
virtual ~rl_MultilayerSurface()
Destructor.
A class encapsulating reflection of a ray from a multilayer surface.
Definition: rl_Multilayer.h:60
rl_DielectricLayer const & layer(int layer_no) const
A class encapsulating the multilayer reflection of a ray.