<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DFNgen: generatingPoints.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">DFNgen
   &#160;<span id="projectnumber">2.0</span>
   </div>
   <div id="projectbrief">DFN Model Generator</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('generating_points_8cpp_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">generatingPoints.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="generating_points_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="generating_points_8h.html">generatingPoints.h</a>&quot;</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &lt;cmath&gt;</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="structures_8h.html">structures.h</a>&quot;</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="vector_functions_8h.html">vectorFunctions.h</a>&quot;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="computational_geometry_8h.html">computationalGeometry.h</a>&quot;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="insert_shape_8h.html">insertShape.h</a>&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment">/********************  Discretize Intersection  ***************************/</span></div><div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="generating_points_8h.html#a22991db6b15a6147e875c27a84402d4c">   18</a></span>&#160;std::vector&lt;Point&gt; <a class="code" href="generating_points_8cpp.html#a22991db6b15a6147e875c27a84402d4c">discretizeLineOfIntersection</a>(<span class="keywordtype">double</span> *pt1, <span class="keywordtype">double</span> *pt2, <span class="keywordtype">double</span> dist){</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;    std::vector&lt;Point&gt; pointsList;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="comment">// If reduced mesh, just save endpoints</span></div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <span class="keywordflow">if</span> (<a class="code" href="input_8h.html#aa98b605ce677adf12fe97d6fa9076b1c">visualizationMode</a> == 1) {</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;        <a class="code" href="struct_point.html">Point</a> pt;</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        pt.<a class="code" href="struct_point.html#ab99c56589bc8ad5fa5071387110a5bc7">x</a> = pt1[0];</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;        pt.<a class="code" href="struct_point.html#afa38be143ae800e6ad69ce8ed4df62d8">y</a> = pt1[1];</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;        pt.<a class="code" href="struct_point.html#a05ba3b1dfcb19430582ae953cbbfbded">z</a> = pt1[2];</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;        pointsList.push_back(pt);</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;        pt.<a class="code" href="struct_point.html#ab99c56589bc8ad5fa5071387110a5bc7">x</a> = pt2[0];</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;        pt.<a class="code" href="struct_point.html#afa38be143ae800e6ad69ce8ed4df62d8">y</a> = pt2[1];</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;        pt.<a class="code" href="struct_point.html#a05ba3b1dfcb19430582ae953cbbfbded">z</a> = pt2[2];</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;        pointsList.push_back(pt);</div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;        <span class="keywordflow">return</span> pointsList;</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    }</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <span class="keywordtype">double</span> v[3] = {pt2[0]-pt1[0], pt2[1]-pt1[1], pt2[2]-pt1[2]}; <span class="comment">// {x2-x1, y2-y1, z2-z1};</span></div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <span class="keywordtype">double</span> p[3] = {pt1[0],pt1[1],pt1[2]}; <span class="comment">// {x1, y1, z1};</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="comment">//    double dist = magnitude((pt1[0]-pt2[0]), (pt1[1]-pt2[1]), (pt1[2]-pt2[2])); // (x1-x2), (y1-y2), (z1-z2));   </span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;   </div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="keywordtype">double</span> nprime = std::ceil(2*dist/<a class="code" href="input_8h.html#a8ee9be1b5aa75abae556de3088cba6d9">h</a>);</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <span class="keywordtype">double</span> hprime = 1/nprime;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    <span class="keywordtype">double</span> *xx = <span class="keyword">new</span> <span class="keywordtype">double</span>[(int)nprime+1];</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="keywordtype">int</span> i;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    <span class="keywordtype">double</span> temp = 0; </div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;    <span class="keywordflow">for</span> (i = 0; i &lt; nprime; i++){ <span class="comment">// Array from 0 - 1 with step = hprime</span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        xx[i] = temp;</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;        temp += hprime;</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;    }</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;    xx[i] = 1; <span class="comment">// Make sure last element is exactly 1  </span></div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;    </div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    pointsList.reserve((<span class="keywordtype">int</span>) nprime+1);</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;    <span class="keywordflow">for</span> (i = 0; i&lt;nprime+1; i++){</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;        pointsList.push_back((<a class="code" href="generating_points_8cpp.html#a1765372f6dbad65b4d7cac36d830bdfe">lineFunction3D</a>(v, p, xx[i])));</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    }</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keyword">delete</span>[] xx;</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    <span class="keywordflow">return</span> pointsList;  </div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;}</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="comment">/*********************** Parametric Line Function *************************/</span></div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="generating_points_8h.html#adb658797956583856890236f9d922f72">   72</a></span>&#160;<a class="code" href="struct_point.html">Point</a> <a class="code" href="generating_points_8cpp.html#a1765372f6dbad65b4d7cac36d830bdfe">lineFunction3D</a>(<span class="keywordtype">double</span> *v, <span class="keywordtype">double</span> *point, <span class="keywordtype">double</span> t){</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <a class="code" href="struct_point.html">Point</a> pt;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    pt.<a class="code" href="struct_point.html#ab99c56589bc8ad5fa5071387110a5bc7">x</a> = point[0] + v[0]*t;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    pt.<a class="code" href="struct_point.html#afa38be143ae800e6ad69ce8ed4df62d8">y</a> = point[1] + v[1]*t;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    pt.<a class="code" href="struct_point.html#a05ba3b1dfcb19430582ae953cbbfbded">z</a> = point[2] + v[2]*t;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keywordflow">return</span> pt;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;}</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;<span class="comment">/****** Fisher Distributions for Generating polygons Normal Vectors *******/</span></div><div class="line"><a name="l00093"></a><span class="lineno"><a class="line" href="generating_points_8h.html#a2f7b981bd314f565407a2db0358bf81b">   93</a></span>&#160;<span class="keywordtype">double</span> *<a class="code" href="generating_points_8cpp.html#a2f7b981bd314f565407a2db0358bf81b">fisherDistribution</a>(<span class="keywordtype">double</span> theta, <span class="keywordtype">double</span> phi, <span class="keywordtype">double</span> kappa, std::mt19937_64 &amp;generator){</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <span class="keywordtype">double</span> ck = (std::exp(kappa) - std::exp(-kappa))/kappa;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    <span class="keywordtype">double</span> v1[3]; </div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    v1[0] = sin(theta)*cos(phi);</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    v1[1] = sin(theta)*sin(phi);</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    v1[2] = cos(theta);</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    </div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="keywordtype">double</span> u[3] = {0,0,1};</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    </div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <span class="keywordtype">double</span> *xProd = <a class="code" href="vector_functions_8h.html#a94303b1c8dd36d71e57fd0e4d5d26ae3">crossProduct</a>(u,v1);</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    <span class="keywordtype">double</span> R[9];</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="comment">// Get rotation matrix if normal vectors are not the same (if xProd is not zero vector)</span></div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    <span class="keywordflow">if</span> (!(std::abs(xProd[0]) &lt;= <a class="code" href="_d_f_nmain_8cpp.html#a974b448c3d0a13d483d36ef15de369b5">eps</a> &amp;&amp; std::abs(xProd[1]) &lt;= <a class="code" href="_d_f_nmain_8cpp.html#a974b448c3d0a13d483d36ef15de369b5">eps</a> &amp;&amp; std::abs(xProd[2]) &lt;= <a class="code" href="_d_f_nmain_8cpp.html#a974b448c3d0a13d483d36ef15de369b5">eps</a> )){</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;        <span class="comment">// Since vectors are normalized, sin = magnitude(AxB) and cos = A . B</span></div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;        <span class="keywordtype">double</span> sin = sqrt(xProd[0]*xProd[0] + xProd[1]*xProd[1] + xProd[2]*xProd[2]);</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;        <span class="keywordtype">double</span> cos = <a class="code" href="vector_functions_8h.html#abb1d4beb5939c7a5ddd4978c15fab7bb">dotProduct</a>(u, v1);</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;        <span class="keywordtype">double</span> v[9] = {0, -xProd[2], xProd[1], xProd[2], 0, -xProd[0], -xProd[1], xProd[0], 0};</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;        <span class="keywordtype">double</span> scalar = (1.0f-cos)/(sin*sin);</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;        <span class="keywordtype">double</span> vSquared[9];</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;        vSquared[0] = (v[0]*v[0] + v[1]*v[3] + v[2]*v[6])*scalar;</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;        vSquared[1] = (v[0]*v[1] + v[1]*v[4] + v[2]*v[7])*scalar;</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;        vSquared[2] = (v[0]*v[2] + v[1]*v[5] + v[2]*v[8])*scalar;</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;        vSquared[3] = (v[3]*v[0] + v[4]*v[3] + v[5]*v[6])*scalar;</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;        vSquared[4] = (v[3]*v[1] + v[4]*v[4] + v[5]*v[7])*scalar;</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;        vSquared[5] = (v[3]*v[2] + v[4]*v[5] + v[5]*v[8])*scalar;</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;        vSquared[6] = (v[6]*v[0] + v[7]*v[3] + v[8]*v[6])*scalar;</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;        vSquared[7] = (v[6]*v[1] + v[7]*v[4] + v[8]*v[7])*scalar;</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;        vSquared[8] = (v[6]*v[2] + v[7]*v[5] + v[8]*v[8])*scalar;</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;        R[0] = 1 + v[0] + vSquared[0];</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;        R[1] = 0 + v[1] + vSquared[1];</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        R[2] = 0 + v[2] + vSquared[2];</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;        R[3] = 0 + v[3] + vSquared[3];</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;        R[4] = 1 + v[4] + vSquared[4];</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;        R[5] = 0 + v[5] + vSquared[5];</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;        R[6] = 0 + v[6] + vSquared[6];</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;        R[7] = 0 + v[7] + vSquared[7];</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;        R[8] = 1 + v[8] + vSquared[8];</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    }</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    <span class="keywordflow">else</span> {</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;            <span class="comment">// Identity Matrix</span></div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;            R[0]=1; R[1]=0; R[2]=0;</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;            R[3]=0; R[4]=1; R[5]=0;</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;            R[6]=0; R[7]=0; R[8]=1;</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    }</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    </div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    <span class="keyword">delete</span>[] xProd; </div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="comment">// Random number generator on [0,1]</span></div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;     </div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    std::uniform_real_distribution&lt;double&gt; thetaDist(0.0,M_PI);</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;    std::uniform_real_distribution&lt;double&gt; distribution(0.0,1.0);</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;    <span class="keywordtype">double</span> thetaRandom = thetaDist(generator);</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;    <span class="keywordtype">double</span> y = distribution(generator);</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;    <span class="keywordtype">double</span> V[2] = {std::cos(thetaRandom), std::sin(thetaRandom)};</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    <span class="keywordtype">double</span> w = 1/kappa*std::log(std::exp(-kappa)+kappa*ck*y);</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="keywordtype">double</span> temp = std::sqrt(1-(w*w));</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;    V[0] = temp*V[0];</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;    V[1] = temp*V[1];</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    <span class="comment">// Matrix multiply with R</span></div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="keywordtype">double</span> *vec = <span class="keyword">new</span> <span class="keywordtype">double</span>[3];</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;    vec[0] =V[0]*R[0] + V[1]*R[1] + w*R[2]; </div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    vec[1] =V[0]*R[3] + V[1]*R[4] + w*R[5];</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;    vec[2] =V[0]*R[6] + V[1]*R[7] + w*R[8];</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;    <span class="keywordflow">return</span> vec;</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;}</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;<span class="comment">/******************* Returns random TRANSLATION ***************************/</span></div><div class="line"><a name="l00177"></a><span class="lineno"><a class="line" href="generating_points_8h.html#a152eb5ef32d8e1dd69785a1e05d9c8c0">  177</a></span>&#160;<span class="keywordtype">double</span> *<a class="code" href="generating_points_8cpp.html#a152eb5ef32d8e1dd69785a1e05d9c8c0">randomTranslation</a>(std::mt19937_64 &amp;generator, <span class="keywordtype">float</span> xMin, <span class="keywordtype">float</span> xMax, <span class="keywordtype">float</span> yMin, <span class="keywordtype">float</span> yMax, <span class="keywordtype">float</span> zMin, <span class="keywordtype">float</span> zMax) {</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;    <span class="keywordtype">double</span> *t = <span class="keyword">new</span> <span class="keywordtype">double</span>[3];</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;    </div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;    <span class="comment">// Setup for getting random x location</span></div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    std::uniform_real_distribution&lt;double&gt; distributionX (xMin, xMax);</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    t[0] = distributionX(generator);</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    <span class="comment">// Setup for getting random y location</span></div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;    std::uniform_real_distribution&lt;double&gt; distributionY (yMin, yMax);</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;    t[1] = distributionY(generator);</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;    <span class="comment">// Setup for getting random z location</span></div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;    std::uniform_real_distribution&lt;double&gt; distributionZ (zMin, zMax);</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    t[2] = distributionZ(generator);        </div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;    <span class="keywordflow">return</span> t;</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;}</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;<span class="comment">/*******************  Truncated Power-Law  ********************************/</span></div><div class="line"><a name="l00208"></a><span class="lineno"><a class="line" href="math_functions_8h.html#a132e593f161b095ca9de50bdc85a3a77">  208</a></span>&#160;<span class="keywordtype">float</span> <a class="code" href="generating_points_8cpp.html#a91e58d3a0d7a5e9d65cf15471f02fab0">truncatedPowerLaw</a>(<span class="keywordtype">float</span> randomNum, <span class="keywordtype">float</span> min, <span class="keywordtype">float</span> max, <span class="keywordtype">float</span> alpha){</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <span class="keywordtype">float</span> temp = 1-randomNum + (randomNum*std::pow((min/max), alpha));</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    temp = min * std::pow(temp,(-1/alpha));  </div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;    </div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    <span class="keywordflow">return</span> temp;</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;}</div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;<span class="comment">/**********  Generates Theta Array for Generating Ellipses  ***************/</span></div><div class="line"><a name="l00224"></a><span class="lineno"><a class="line" href="generating_points_8h.html#a15a7dfd1320eb3c7c3cc2c53ed4ba2c1">  224</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="generating_points_8cpp.html#a15a7dfd1320eb3c7c3cc2c53ed4ba2c1">generateTheta</a>(<span class="keywordtype">float</span> * &amp;thetaArray, <span class="keywordtype">float</span> aspectRatio, <span class="keywordtype">int</span> nPoints){</div><div class="line"><a name="l00225"></a><span class="lineno">  225</span>&#160;     <span class="comment">// a = x radius</span></div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;     <span class="comment">// b = y radius</span></div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160; </div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;     <span class="keywordtype">float</span> a = 1;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;     <span class="keywordtype">float</span> b = aspectRatio;</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160; </div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;     <span class="keywordtype">double</span> temp1 = ((a-b)/(a+b));</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;     temp1 = temp1*temp1;</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;     <span class="keywordtype">double</span> c = M_PI *(a+b)*(1 + (3 * temp1)/(10 + std::sqrt(4-3 * temp1)));</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160; </div><div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;     <span class="keywordtype">double</span> del = c/nPoints;</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160; </div><div class="line"><a name="l00237"></a><span class="lineno">  237</span>&#160;     thetaArray = <span class="keyword">new</span> <span class="keywordtype">float</span>[nPoints];</div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;     thetaArray[0] = 0;</div><div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160; </div><div class="line"><a name="l00240"></a><span class="lineno">  240</span>&#160;     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 1; i &lt; nPoints; i++) {</div><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;         <span class="keywordtype">double</span> tmp; </div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160; </div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;         tmp = std::pow(b *std::cos(thetaArray[i-1]),2) + (std::pow((a * std::sin(thetaArray[i-1])),2));</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160; </div><div class="line"><a name="l00245"></a><span class="lineno">  245</span>&#160;         <span class="keywordtype">double</span> f_tmp = del / std::sqrt(tmp);</div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160; </div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;         tmp = thetaArray[i-1] + f_tmp;</div><div class="line"><a name="l00248"></a><span class="lineno">  248</span>&#160;</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;         thetaArray[i] = thetaArray[i-1] + 0.5*del*std::pow(std::sqrt(std::pow(b*std::cos(tmp),2) + std::pow(a*std::sin(tmp), 2)),(-1)) + 0.5*f_tmp;</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;     }</div><div class="line"><a name="l00251"></a><span class="lineno">  251</span>&#160;}</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;</div><div class="line"><a name="l00254"></a><span class="lineno">  254</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;<span class="comment">/**************************************************************************/</span></div><div class="line"><a name="l00263"></a><span class="lineno"><a class="line" href="generating_points_8h.html#aa3af81bf42f3459e297870e04f2966c0">  263</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="generating_points_8cpp.html#aa3af81bf42f3459e297870e04f2966c0">greaterThan</a>(<span class="keywordtype">float</span> i, <span class="keywordtype">float</span> j) { <span class="keywordflow">return</span> (i &gt; j); } </div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;</div><div class="line"><a name="l00265"></a><span class="lineno">  265</span>&#160;</div><div class="ttc" id="computational_geometry_8h_html"><div class="ttname"><a href="computational_geometry_8h.html">computationalGeometry.h</a></div></div>
<div class="ttc" id="_d_f_nmain_8cpp_html_a974b448c3d0a13d483d36ef15de369b5"><div class="ttname"><a href="_d_f_nmain_8cpp.html#a974b448c3d0a13d483d36ef15de369b5">eps</a></div><div class="ttdeci">double eps</div><div class="ttdef"><b>Definition:</b> <a href="_d_f_nmain_8cpp_source.html#l00039">DFNmain.cpp:39</a></div></div>
<div class="ttc" id="struct_point_html"><div class="ttname"><a href="struct_point.html">Point</a></div><div class="ttdef"><b>Definition:</b> <a href="structures_8h_source.html#l00111">structures.h:111</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_aa3af81bf42f3459e297870e04f2966c0"><div class="ttname"><a href="generating_points_8cpp.html#aa3af81bf42f3459e297870e04f2966c0">greaterThan</a></div><div class="ttdeci">bool greaterThan(float i, float j)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00263">generatingPoints.cpp:263</a></div></div>
<div class="ttc" id="struct_point_html_afa38be143ae800e6ad69ce8ed4df62d8"><div class="ttname"><a href="struct_point.html#afa38be143ae800e6ad69ce8ed4df62d8">Point::y</a></div><div class="ttdeci">double y</div><div class="ttdef"><b>Definition:</b> <a href="structures_8h_source.html#l00113">structures.h:113</a></div></div>
<div class="ttc" id="vector_functions_8h_html"><div class="ttname"><a href="vector_functions_8h.html">vectorFunctions.h</a></div></div>
<div class="ttc" id="structures_8h_html"><div class="ttname"><a href="structures_8h.html">structures.h</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_a91e58d3a0d7a5e9d65cf15471f02fab0"><div class="ttname"><a href="generating_points_8cpp.html#a91e58d3a0d7a5e9d65cf15471f02fab0">truncatedPowerLaw</a></div><div class="ttdeci">float truncatedPowerLaw(float randomNum, float min, float max, float alpha)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00208">generatingPoints.cpp:208</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_a152eb5ef32d8e1dd69785a1e05d9c8c0"><div class="ttname"><a href="generating_points_8cpp.html#a152eb5ef32d8e1dd69785a1e05d9c8c0">randomTranslation</a></div><div class="ttdeci">double * randomTranslation(std::mt19937_64 &amp;generator, float xMin, float xMax, float yMin, float yMax, float zMin, float zMax)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00177">generatingPoints.cpp:177</a></div></div>
<div class="ttc" id="struct_point_html_ab99c56589bc8ad5fa5071387110a5bc7"><div class="ttname"><a href="struct_point.html#ab99c56589bc8ad5fa5071387110a5bc7">Point::x</a></div><div class="ttdeci">double x</div><div class="ttdef"><b>Definition:</b> <a href="structures_8h_source.html#l00112">structures.h:112</a></div></div>
<div class="ttc" id="generating_points_8h_html"><div class="ttname"><a href="generating_points_8h.html">generatingPoints.h</a></div></div>
<div class="ttc" id="insert_shape_8h_html"><div class="ttname"><a href="insert_shape_8h.html">insertShape.h</a></div></div>
<div class="ttc" id="vector_functions_8h_html_abb1d4beb5939c7a5ddd4978c15fab7bb"><div class="ttname"><a href="vector_functions_8h.html#abb1d4beb5939c7a5ddd4978c15fab7bb">dotProduct</a></div><div class="ttdeci">T dotProduct(const T *A, const T *B)</div><div class="ttdef"><b>Definition:</b> <a href="vector_functions_8h_source.html#l00058">vectorFunctions.h:58</a></div></div>
<div class="ttc" id="input_8h_html_aa98b605ce677adf12fe97d6fa9076b1c"><div class="ttname"><a href="input_8h.html#aa98b605ce677adf12fe97d6fa9076b1c">visualizationMode</a></div><div class="ttdeci">bool visualizationMode</div><div class="ttdef"><b>Definition:</b> <a href="read_input_8cpp_source.html#l00036">readInput.cpp:36</a></div></div>
<div class="ttc" id="struct_point_html_a05ba3b1dfcb19430582ae953cbbfbded"><div class="ttname"><a href="struct_point.html#a05ba3b1dfcb19430582ae953cbbfbded">Point::z</a></div><div class="ttdeci">double z</div><div class="ttdef"><b>Definition:</b> <a href="structures_8h_source.html#l00114">structures.h:114</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_a2f7b981bd314f565407a2db0358bf81b"><div class="ttname"><a href="generating_points_8cpp.html#a2f7b981bd314f565407a2db0358bf81b">fisherDistribution</a></div><div class="ttdeci">double * fisherDistribution(double theta, double phi, double kappa, std::mt19937_64 &amp;generator)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00093">generatingPoints.cpp:93</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_a15a7dfd1320eb3c7c3cc2c53ed4ba2c1"><div class="ttname"><a href="generating_points_8cpp.html#a15a7dfd1320eb3c7c3cc2c53ed4ba2c1">generateTheta</a></div><div class="ttdeci">void generateTheta(float *&amp;thetaArray, float aspectRatio, int nPoints)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00224">generatingPoints.cpp:224</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_a1765372f6dbad65b4d7cac36d830bdfe"><div class="ttname"><a href="generating_points_8cpp.html#a1765372f6dbad65b4d7cac36d830bdfe">lineFunction3D</a></div><div class="ttdeci">Point lineFunction3D(double *v, double *point, double t)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00072">generatingPoints.cpp:72</a></div></div>
<div class="ttc" id="input_8h_html_a8ee9be1b5aa75abae556de3088cba6d9"><div class="ttname"><a href="input_8h.html#a8ee9be1b5aa75abae556de3088cba6d9">h</a></div><div class="ttdeci">double h</div><div class="ttdef"><b>Definition:</b> <a href="read_input_8cpp_source.html#l00021">readInput.cpp:21</a></div></div>
<div class="ttc" id="vector_functions_8h_html_a94303b1c8dd36d71e57fd0e4d5d26ae3"><div class="ttname"><a href="vector_functions_8h.html#a94303b1c8dd36d71e57fd0e4d5d26ae3">crossProduct</a></div><div class="ttdeci">T * crossProduct(const T *v1, const T *v2)</div><div class="ttdef"><b>Definition:</b> <a href="vector_functions_8h_source.html#l00024">vectorFunctions.h:24</a></div></div>
<div class="ttc" id="generating_points_8cpp_html_a22991db6b15a6147e875c27a84402d4c"><div class="ttname"><a href="generating_points_8cpp.html#a22991db6b15a6147e875c27a84402d4c">discretizeLineOfIntersection</a></div><div class="ttdeci">std::vector&lt; Point &gt; discretizeLineOfIntersection(double *pt1, double *pt2, double dist)</div><div class="ttdef"><b>Definition:</b> <a href="generating_points_8cpp_source.html#l00018">generatingPoints.cpp:18</a></div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="generating_points_8cpp.html">generatingPoints.cpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
  </ul>
</div>
</body>
</html>
