rl_raylib  1.1.10
rl_Ray.h
1 #ifndef rl_Ray_h_INCLUDED
2 #define rl_Ray_h_INCLUDED
3 
4 // File: rl_Ray.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 <rl_basicray/rl_BasicRay.h> // rl_BasicRay
32 #include <rl_raylib/rl_Polarization.h> // rl_Polarization
33 #include <dvm3/dvm3_vector.h> // dmv3_Vector
34 
35 //########################################################################
36 // rl_Ray
37 //########################################################################
38 
45 class rl_Ray
46  : public rl_BasicRay
47 {
48 private:
49 
51  rl_Polarization pol_;
52 
53 public:
54 
55 
59  virtual ~rl_Ray();
60 
65  rl_Ray();
66 
71  rl_Ray( rl_BasicRay const& ray, rl_PolCSPOD const& cspol );
72 
82  rl_Ray( dvm3_Vector const& pos, dvm3_Vector const& dir,
83  double energy, long int id,
84  rl_PolCSPOD const& cspol );
85 
95  void init_ray( dvm3_Vector const& pos, dvm3_Vector const& dir,
96  double energy, long int id,
97  rl_PolCSPOD const& cspol );
98 
104  rl_Polarization const& polarization() const;
105 
111  void set_polarization( rl_PolCSPOD const& cspol );
112 
118  void get_PolCSPOD( rl_PolCSPOD& cs ) const;
119 
125  double intensity() const;
126 
132  void attenuate( double by_how_much );
133 
140  void reflect( dvm3_Vector const& normal,
141  rl_ReflectionCoefPOD const& rflcoef );
142 
150  void translate_rotate( dvm3_Vector const& trans,
151  dvm3_RotMat const& rotmat );
152 
161  void derotate_detranslate( dvm3_Vector const& trans,
162  dvm3_RotMat const& rotmat );
163 
171  std::ostream& print_on( std::ostream& os, char const pre[] = "",
172  char const pst[] = "" ) const;
173 };
174 
175 //########################################################################
176 //########################################################################
177 //
178 // # # # # # # # ###### ####
179 // # ## # # # ## # # #
180 // # # # # # # # # # ##### ####
181 // # # # # # # # # # # #
182 // # # ## # # # ## # # #
183 // # # # ###### # # # ###### ####
184 //
185 //########################################################################
186 //########################################################################
187 
188 //=========================================================================
189 // dtor, ctors, initializers...
190 
191 //-------------------------------------------------------------------------
192 inline rl_Ray::
194 {}
195 
196 //-------------------------------------------------------------------------
197 inline rl_Ray::
198 rl_Ray( rl_BasicRay const& ray, rl_PolCSPOD const& cspol )
199  : rl_BasicRay( ray ), pol_( cspol, ray.direction() )
200 {}
201 
202 inline rl_Ray::
203 rl_Ray( dvm3_Vector const& pos, dvm3_Vector const& dir,
204  double energy, long int id,
205  rl_PolCSPOD const& cspol )
206  : rl_BasicRay( pos, dir, energy, id ),
207  pol_( cspol, dir )
208 {}
209 
210 inline void rl_Ray::
211 init_ray( dvm3_Vector const& pos, dvm3_Vector const& dir,
212  double energy, long int id,
213  rl_PolCSPOD const& cspol )
214 {
215  rl_BasicRay::init( pos, dir, energy, id );
216  pol_.init( cspol, dir );
217 }
218 
219 //=========================================================================
220 // accessors
221 
222 //-------------------------------------------------------------------------
223 inline rl_Polarization const& rl_Ray::
225 { return pol_; }
226 
227 //-------------------------------------------------------------------------
228 inline void rl_Ray::
230 { pol_.get_PolCSPOD( cs, dir_); }
231 
232 //-------------------------------------------------------------------------
233 inline double rl_Ray::
234 intensity() const
235 { return pol_.intensity(); }
236 
237 //=========================================================================
238 // mutators
239 
240 //-------------------------------------------------------------------------
241 inline void rl_Ray::
243 { pol_.init( cspol, dir_ ); }
244 
245 //-------------------------------------------------------------------------
246 inline void rl_Ray::
247 attenuate( double by_how_much )
248 { pol_.attenuate( by_how_much ); }
249 
250 // rl_Ray_h_INCLUDED
251 #endif
void translate_rotate(dvm3_Vector const &trans, dvm3_RotMat const &rotmat)
Translate to BCS origin and rotate from STD to BCS coordinates.
Definition: rl_Ray.cc:63
rl_Ray()
Default constructor.
Definition: rl_Ray.h:193
void init_ray(dvm3_Vector const &pos, dvm3_Vector const &dir, double energy, long int id, rl_PolCSPOD const &cspol)
Initialize a ray.
Definition: rl_Ray.h:211
double intensity() const
Returns this ray's normalized intensity (i.e., "weight")
Definition: rl_Ray.h:234
std::ostream & print_on(std::ostream &os, char const pre[]="", char const pst[]="") const
Write the ray contents with optional pre and post comment strings.
Definition: rl_Ray.cc:86
virtual ~rl_Ray()
Destructor.
Definition: rl_Ray.cc:41
An rl_BasicRay with added polarization information.
Definition: rl_Ray.h:45
void get_PolCSPOD(rl_PolCSPOD &cs) const
Evaluate rl_PolCSPOD corresponding to this ray's polarization state.
Definition: rl_Ray.h:229
void reflect(dvm3_Vector const &normal, rl_ReflectionCoefPOD const &rflcoef)
Reflect this ray's direction vector and polarization state.
Definition: rl_Ray.cc:51
void attenuate(double by_how_much)
Attenuate this ray by by_how_much.
Definition: rl_Ray.h:247
A Plain Ol' Data class representing complex reflection coefficients.
A Plain Ol' Data struct (POD) encapsulating the OSAC-style complex polarization amplitudes.
void attenuate(double factor)
Attenuate reflectivity by a factor.
void init(rl_PolCSPOD const &cs, dvm3_Vector const &dir)
Initialize the polarization state.
void get_PolCSPOD(rl_PolCSPOD &cs, dvm3_Vector const &dir) const
Evaluate rl_PolCSPOD corresponding to this polarization state.
Encapsulates the polarization state of a ray.
double intensity() const
Evaluate intensity.
void set_polarization(rl_PolCSPOD const &cspol)
Set the polarization state.
Definition: rl_Ray.h:242
void derotate_detranslate(dvm3_Vector const &trans, dvm3_RotMat const &rotmat)
Derotate back to std coordinates; detranslate back to std origin.
Definition: rl_Ray.cc:75
rl_Polarization const & polarization() const
Return the polarization state.
Definition: rl_Ray.h:224