USGS

Isis 3.0 Object Programmers' Reference

Home

Minnaert.cpp
1 #include <cmath>
2 #include "Minnaert.h"
3 #include "IException.h"
4 
5 namespace Isis {
6  Minnaert::Minnaert(Pvl &pvl) : PhotoModel(pvl) {
7  PvlGroup &algo = pvl.findObject("PhotometricModel")
8  .findGroup("Algorithm", Pvl::Traverse);
9  // Set default value
10  SetPhotoK(1.0);
11  // Get value from user
12  if(algo.hasKeyword("K")) SetPhotoK(algo["K"]);
13  }
14 
23  void Minnaert::SetPhotoK(const double k) {
24  p_photoK = k;
25  }
26 
27  double Minnaert::PhotoModelAlgorithm(double phase, double incidence,
28  double emission) {
29  static double pht_minnaert;
30  double incrad;
31  double emarad;
32  double munot;
33  double mu;
34 
35  static double old_phase = -9999;
36  static double old_incidence = -9999;
37  static double old_emission= -9999;
38 
39  if (old_phase == phase && old_incidence == incidence && old_emission == emission) {
40  return pht_minnaert;
41  }
42 
43  old_phase = phase;
44  old_incidence = incidence;
45  old_emission = emission;
46 
47  incrad = incidence * Isis::PI / 180.0;
48  emarad = emission * Isis::PI / 180.0;
49  munot = cos(incrad);
50  mu = cos(emarad);
51 
52  if(munot <= 0.0 || mu <= 0.0 || incidence == 90.0 ||
53  emission == 90.0) {
54  pht_minnaert = 0.0;
55  }
56 // else if(PhotoK() == 1.0) {
57  else if(p_photoK == 1.0) {
58  pht_minnaert = munot;
59  }
60  else {
61 // pht_minnaert = munot * pow((munot * mu), (PhotoK() - 1.0));
62  pht_minnaert = munot * pow((munot * mu), (p_photoK - 1.0));
63  }
64 
65  return pht_minnaert;
66  }
67 }
68 
69 extern "C" Isis::PhotoModel *MinnaertPlugin(Isis::Pvl &pvl) {
70  return new Isis::Minnaert(pvl);
71 }