Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Zernike'
Browse files Browse the repository at this point in the history
# Conflicts:
#	docs/download.htm
#	docs/index.htm
  • Loading branch information
thomas-germer committed Oct 19, 2017
2 parents 653a55b + 6d71f34 commit b22e463
Show file tree
Hide file tree
Showing 9 changed files with 763 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

*.htm#
*.htm#
*.htm#
*.htm#
2 changes: 2 additions & 0 deletions code/reg_brdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "transmit.h"
#include "rcw.h"
#include "crossrcw.h"
#include "zernikeexpansion.h"

namespace SCATMECH {

Expand All @@ -43,6 +44,7 @@ namespace SCATMECH {
Register_Model(Transmit_BRDF_Model);
Register_Model(RCW_BRDF_Model);
Register_Model(CrossRCW_BRDF_Model);
Register_Model(ZernikeExpansion_BRDF_Model);

}
}
Expand Down
47 changes: 34 additions & 13 deletions code/zernikeexpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
using namespace std;
using namespace SCATMECH;

////
//// ZernikeExpansion_BRDF_Model implements the model described in
//// T.A. Germer, "Full four-dimensional and reciprocal Mueller matrix
//// bidirectional reflectance distribution function of
//// sintered polytetrafluoroethylene," Appl. Opt., in press (2017).
////

namespace SCATMECH {

///
Expand Down Expand Up @@ -52,11 +59,19 @@ void ZernikeExpansion_BRDF_Model::setup()
// The model uses the xyxy basis, rather than the default psps
model_cs = xyxy;

// This code does not accept anything for transmission mode or for
// radiation upwelling in the material
throw_transmission();
throw_backward();

// Check that coefficientfile has been specified
if (coefficientfile.size() == 0) throw("No coefficient file specified");

// Open the coefficient file
ifstream_with_comments cfile(coefficientfile.c_str());

// Throw exception if the coefficient file doesn't open
if (!cfile) error("Cannot open coefficient file.");
if (!cfile) error(string("Cannot open coefficient file '") + coefficientfile + string("'"));

// Clear the list of coefficients
coeff.clear();
Expand Down Expand Up @@ -95,11 +110,15 @@ void ZernikeExpansion_BRDF_Model::setup()
// If there was a failure, then throw an exception
if (sline.fail()) error("Error reading a line in coefficient file");

// Check some ranges...
if (i < 1 || i > 4) error("i = " + to_string(i) + " out of range in coefficient file");
if (j < 1 || j > 4) error("j = " + to_string(j) + " out of range in coefficient file");
if (p < 0 || p > 4) error("p = " + to_string(p) + " out of range in coefficient file");

// Push the coefficient onto the list of coefficients
coeff.push_back(Coefficient(i,j,n,m,k,l,p,c));
}
}
return;
}

MuellerMatrix ZernikeExpansion_BRDF_Model::mueller()
Expand All @@ -108,11 +127,6 @@ MuellerMatrix ZernikeExpansion_BRDF_Model::mueller()
// routines that use
SETUP();

// This code does not accept anything for transmission mode or for
// radiation upwelling in the material
throw_transmission();
throw_backward();

// Start the sum with zero
MuellerMatrix result = MuellerZero();
double brdf = 0;
Expand All @@ -123,6 +137,14 @@ MuellerMatrix ZernikeExpansion_BRDF_Model::mueller()
double phii = pi-rotation;
double phir = phis-rotation;

// Create a table of powers of lambda
double lambdapower[5];
lambdapower[0] = 1.;
lambdapower[1] = lambda;
lambdapower[2] = lambdapower[1] * lambda;
lambdapower[3] = lambdapower[2] * lambda;
lambdapower[4] = lambdapower[3] * lambda;

// Iterate through all the coefficients...
for (list<Coefficient>::iterator q=coeff.begin();q!=coeff.end();++q) {
short i = q->i;
Expand All @@ -134,8 +156,7 @@ MuellerMatrix ZernikeExpansion_BRDF_Model::mueller()
short p = q->p;
double coeff = q->coeff;

// The following just evaluates lambda^p
double power = p==0?1.:p==1?lambda:p==2?sqr(lambda):p==3?sqr(lambda):pow(lambda,p);
double power = lambdapower[p];

if (i==1&&j==1) {
// The basis set for the unpolarized BRDF...
Expand All @@ -148,7 +169,7 @@ MuellerMatrix ZernikeExpansion_BRDF_Model::mueller()
result[i-1][j-1] += coeff * prefact * (Radial_Zernike_Polynomial(n,k,rhoi)*Radial_Zernike_Polynomial(m,l,rhor)*az(k,phii)*az(l,phir) +
Radial_Zernike_Polynomial(m,l,rhoi)*Radial_Zernike_Polynomial(n,k,rhor)*az(k,phir)*az(l,phii));
} else if (i<j) {
// The baiss set for the off-diagonal elements...
// The basis set for the off-diagonal elements...
double prefact = sqrt((n+1.)*(m+1.))/pi*power;
result[i-1][j-1] += coeff * prefact * Radial_Zernike_Polynomial(n,k,rhoi)*Radial_Zernike_Polynomial(m,l,rhor)*az(k,phii)*az(l,phir);
result[j-1][i-1] += coeff * prefact * Radial_Zernike_Polynomial(n,k,rhor)*Radial_Zernike_Polynomial(m,l,rhoi)*az(k,phir)*az(l,phii);
Expand All @@ -163,18 +184,18 @@ MuellerMatrix ZernikeExpansion_BRDF_Model::mueller()
result[3][2] = -result[3][2];

// Change to un-normalized Mueller matrix...
result *= brdf*scale;
result *= brdf*scale.value(lambda);

// And return!
return result;
}

//
// These are required for Models in SCATMECH...
// These are required for registration of Models ...
//
DEFINE_MODEL(ZernikeExpansion_BRDF_Model,BRDF_Model,"Model using the model of Koenderink and van Doorn, extended by Germer to include the Mueller matrix");
DEFINE_PARAMETER(ZernikeExpansion_BRDF_Model,string,coefficientfile,"File containing coefficients","",0xFF);
DEFINE_PARAMETER(ZernikeExpansion_BRDF_Model,double,scale,"Scale factor","1",0xFF);
DEFINE_PARAMETER(ZernikeExpansion_BRDF_Model,Table,scale,"Scale factor","1",0xFF);


} // namespace SCATMECH;
4 changes: 2 additions & 2 deletions code/zernikeexpansion.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ namespace SCATMECH {
/// J.J. Koenderink and A.J. van Doorn, "Phenomenological description of bidirectional surface reflection," J. Opt. Soc. Am. A vol. 15, pp. 2903-2912 (1998)
/// as extended by
/// T.A. Germer, "Full four-dimensional and reciprocal Mueller matrix bidirectional reflectance distribution function of sintered polytetrafluoroethylene,"
/// Appl. Opt., to be submitted (2017)
/// Appl. Opt., in press (2017)
///
class ZernikeExpansion_BRDF_Model : public BRDF_Model {
public:

// List of the parameters ...
DECLARE_MODEL();
DECLARE_PARAMETER(std::string,coefficientfile); /// File containing indices and coefficients
DECLARE_PARAMETER(double,scale); /// An overall scale factor (if the coefficients correspond to unit reflectance)
DECLARE_PARAMETER(Table,scale); /// An overall scale factor (if the coefficients correspond to unit reflectance)

// Function evaluating Mueller matrix
MuellerMatrix mueller();
Expand Down
2 changes: 2 additions & 0 deletions docs/classes.htm
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ <h2>Surface Scattering Models</h2>
<li><a href="rcwbrdf.htm">class RCW_BRDF_Model</a></li>

<li><a href="crossrcwbrdf.htm">class CrossRCW_BRDF_Model</a></li>
<li><a href="zernikeexpansion.htm">class ZernikeExpansion_BRDF_Model</a></li>

</ul>
</ul>

Expand Down
182 changes: 182 additions & 0 deletions docs/coatedmiescat.htm~
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<html>
<head>
<meta name="generator" content=
"HTML Tidy for Cygwin (vers 1st September 2004), see www.w3.org">
<link rel="STYLESHEET" href="style.css" type="text/css">

<title>SCATMECH: CoatedMieScatterer</title>
<script language="JavaScript" id="_fed_an_js_tag" src="/js/federated-analytics.all.min.js?agency=NIST&subagency=pml&pua=UA-37115410-46&yt=true"></script>
</head>

<body>
<a name="top" id="top"><!-- --></a>

<table width="98%" border="0" cellpadding="0" cellspacing="0"
align="center">
<tr>
<td>
<p class="nav"><a href="index.htm">SCATMECH</a> &gt; <a href=
"classes.htm">Classes and Functions</a> &gt;
<a href="classes.htm#FSSM">Free-Space Scattering Models</a>
&gt; CoatedMieScatterer</p>

<h1>class CoatedMieScatterer</h1>

<hr>

<p>A <b>CoatedMieScatterer</b> is a <a href=
"sphrscat.htm">SphericalScatterer</a> for a uniform
isotropic sphere with a uniform coating.

<h2>Parameters:</h2>

<table border="1" cellpadding="5">
<tr>
<th>Parameter</th>
<th>Data Type</th>
<th>Description</th>
<th>Default</th>
</tr>

<tr>
<td class="parameter">lambda</td>

<td class="datatype">double</td>

<td class="description">Wavelength of the light
[&#181;m].<br>
(Inherited from <a href=
"freescat.htm">Free_Space_Scatterer</a>.)</td>

<td class="default">0.532</td>
</tr>

<tr>
<td class="parameter">medium</td>

<td class="datatype"><a href="dielfunc.htm">dielectric_function</a></td>

<td class="description">The
optical constants of the medium surrounding the sphere,
expressed as a complex number (n,k) or, optionally, as
a function of wavelength.<br>
(Inherited from <a href=
"freescat.htm">Free_Space_Scatterer</a>.)</td>

<td class="default">(1,0)</td>
</tr>

<tr>
<td class="parameter">sphere</td>

<td class="datatype"><a href="dielfunc.htm">dielectric_function</a></td>

<td class="description">The
optical constants of the sphere, expressed as a complex
number (n,k) or, optionally, as a function of
wavelength.<br>
(Inherited from <a href=
"sphrscat.htm">SphericalScatterer</a>.)</td>

<td class="default">(1.59,0)</td>
</tr>

<tr>
<td class="parameter">radius</td>

<td class="datatype">double</td>

<td class="description">Total radius of
the sphere [&#181;m], including the coating.<br>
(Inherited from <a href=
"sphrscat.htm">SphericalScatterer</a>.)</td>

<td class="default">0.05</td>
</tr>

<tr>
<td class="parameter">coating</td>

<td class="datatype"><a href="dielfunc.htm">dielectric_function</a></td>

<td class="description">The
optical constants of the sphere coating, expressed as a
complex number (n,k) or, optionally, as a function of
wavelength.</td>

<td class="default">(1,0)</td>
</tr>

<tr>
<td class="parameter">thickness</td>

<td class="datatype">double</td>

<td class="description">Thickness
of the sphere coating [&#181;m]. The value must be positive and less than <tt>radius</tt>.</td>

<td class="default">0</td>
</tr>
</table>

<h2>See also:</h2>

<p><a href=
"index.htm">SCATMECH Home</a>, &nbsp; <a href=
"convent.htm">Conventions</a>, &nbsp; <a href=
"sphrscat.htm">SphericalScatterer</a>, &nbsp; <a href=
"rayscat.htm">RayleighScatterer</a>, &nbsp; <a href=
"raygscat.htm">RayleighGansSphericalScatterer</a> <a href=
"miescat.htm">MieScatterer</a></p>

<p>
<a name="RefBohren" id="RefBohren"></a><a href="http://dx.doi.org/10.1002/9783527618156">C.F. Bohren and D.R. Huffman, <i>Absorption and Scattering of Light by Small Particles</i>, (Wiley, New York, 1983).</a><br>
<a name="RefHulst" id="RefHulst"></a><a href="https://books.google.com/books?hl=en&lr=&id=PlHfPMVAFRcC&oi=fnd&pg=PA1&ots=Gg_gMuimH7&sig=gqf0sZ1ELYIDmyxa0vLzXIPcLWs">H.C. van de Hulst, <i>Light Scattering by Small Particles</i>, (Dover, New York, 1981).</a><br>


<h2>Include file:</h2>

<pre>
#include "<a href="../code/coatedmie.h">coatedmie.h</a>"
</pre>
<h2>Source code:</h2>

<pre>
<a href="../code/coatedmie.cpp">coatedmie.cpp</a>
</pre>
<h2>Definition of public elements:</h2>

<pre>
class CoatedMieScatterer: public <a href=
"sphrscat.htm">SphericalScatterer</a>
{
};
</pre>

<p><a href="#top"><span class="totop">Top of Page</span></a></p>

<!-- START FOOTER -->
<hr>
<h2>For More Information</h2>

<p>
<a href="http://www.nist.gov/pml/div685/grp06/germer.cfm">SCATMECH Technical Information and Questions</a><br>
<a href="http://www.nist.gov/pml/div685/index.cfm" target="_top">Sensor Science Division Home Page</a><br>
<a href="mailto:fraser@nist.gov">Sensor Science Division Inquiries</a><br>
<a href="mailto:thomas.germer@nist.gov">Website Comments</a>

<p>
Current SCATMECH version: <a href="./download.htm">7.00 (January 2015)</a><br>
This page first online: Version 4.00 (July 2003) <br>
This page last modified: Version 7.00 (January 2015) <br>

<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>

</td>
</tr>
</table>

</body>
</html>

9 changes: 8 additions & 1 deletion docs/history.htm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ <h1><a name="top" id="top">Version History</a></h1>
<hr>

<ul>
<li><a href="#v7.10">Version 7.10</a> (October 2017)</li>

<li><a href="#v7.01">Version 7.01</a> (September 2017)</li>

<li><a href="#v7.00">Version 7.00</a> (January 2015)</li>
Expand Down Expand Up @@ -53,7 +55,12 @@ <h1><a name="top" id="top">Version History</a></h1>

<li>Version 1.00 (March 2000)</li>
</ul>
<a name="v7.01" id="v7.01"><!-- --></a>
<a name="v7.10" id="v7.10"><!-- --></a>
<h2>Version 7.10 (October 2017)</h2>

The model <a href="./zernikeexpansion.htm">ZernikeExpansion_BRDF_Model</a> was added.

<a name="v7.01" id="v7.01"><!-- --></a>
<h2>Version 7.01 (September 2017)</h2>


Expand Down
Loading

0 comments on commit b22e463

Please sign in to comment.