Changeset 19637 for trunk/Mars/msimreflector
- Timestamp:
- 09/15/19 14:21:31 (5 years ago)
- Location:
- trunk/Mars/msimreflector
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/msimreflector/MOptics.cc
r19629 r19637 168 168 return false; 169 169 170 u.fRealPart *= n 1/n2;170 u.fRealPart *= n2/n1; 171 171 return true; 172 172 } … … 258 258 // n1 is always the medium where the photon comes from. 259 259 // 260 // Uses Fresnel's equation for calculating reflection 260 // Uses Fresnel's equation for calculating reflection. Total internal 261 // reflection above the critical angle will always take place. Fresnel 262 // reflection will only be calculated if 'fresnel' is set to true (default). 263 // For Fresnel reflection, a random number is produced according to the 264 // calculated reflectivity to decide whether the ray is reflected or 265 // refracted. 266 // 261 267 // 262 268 // The direction of the normal vector does not matter, it is automatically … … 276 282 // 4 refraction applied 277 283 // 278 int MOptics::ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2 )284 int MOptics::ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2, bool fresnel) 279 285 { 280 286 if (n1==n2) … … 309 315 const double reflectivity = (Rt*Rt + Rp*Rp)/2; 310 316 311 if ( gRandom->Uniform()<reflectivity)317 if (fresnel && gRandom->Uniform()<reflectivity) 312 318 { 313 319 // ----- Case of reflection ---- … … 327 333 const int rc = ApplyTransitionFast(u.fVectorPart, n, n1, n2); 328 334 if (rc>=3) 329 u.fRealPart *= n 1/n2;335 u.fRealPart *= n2/n1; 330 336 return rc; 331 337 } 332 338 333 int MOptics::ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2 )334 { 335 const int rc = ApplyTransition(u.fVectorPart, n, n1, n2 );339 int MOptics::ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2, bool fresnel) 340 { 341 const int rc = ApplyTransition(u.fVectorPart, n, n1, n2, fresnel); 336 342 if (rc>=3) 337 u.fRealPart *= n 1/n2;343 u.fRealPart *= n2/n1; 338 344 return rc; 339 345 } -
trunk/Mars/msimreflector/MOptics.h
r19629 r19637 35 35 static int ApplyTransitionFast(MQuaternion &u, const TVector3 &n, double n1, double n2); 36 36 37 static int ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2 );38 static int ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2 );37 static int ApplyTransition(TVector3 &u, TVector3 n, double n1, double n2, bool fresnel=true); 38 static int ApplyTransition(MQuaternion &u, const TVector3 &n, double n1, double n2, bool fresnel=true); 39 39 40 40 ClassDef(MOptics, 1) // Base class for optics (reflector, lens)
Note:
See TracChangeset
for help on using the changeset viewer.