<div dir="ltr">Dear yt users,<div><br></div><div>I am trying to use the pf.h.surface routine, for example on density:</div><div><br></div><div><i>surface=pf.h.surface(primary,"Density",external_density)</i><br></div>
<div><i><br></i></div><div>and then using the sum of the triangles area (via surface.triangles) as an estimate of the surface area. But this method is giving me a wrong value in a test dataset, where I already know the right value for the surface area.</div>
<div> </div><div>I would like hence to ask if there is a better way to estimate the surface area of an iso-quantity surface, or if the process I am following is wrong. Below are the commands I am using to estimate the surface:<br>
</div><div><br></div><div><div><i><span class="" style="white-space:pre">           </span>#computes the surface of the equidensity surface at the desired density</i></div><div><i><span class="" style="white-space:pre">         </span> #obtains the vertices of the triangles composing the surface tassellation approximation</i></div>
<div><i><span class="" style="white-space:pre">           </span>surface=pf.h.surface(primary,"Density",density)</i></div><div><i><span class="" style="white-space:pre">               </span>surface_density = surface['Density']</i></div>
<div><i><span class="" style="white-space:pre">           </span>surface_trg_vertices = surface.triangles</i></div><div><span class="" style="white-space:pre"><i>                </i></span></div><div><i><span class="" style="white-space:pre">                </span> #rearranges the arrays with the vertex of the triangles (coordinates names: a, b, c) to simplify the vectorial computation</i></div>
<div><i><span class="" style="white-space:pre">           </span>a_x = surface_trg_vertices[:,0][:,0]</i></div><div><i><span class="" style="white-space:pre">            </span>a_y = surface_trg_vertices[:,0][:,1]</i></div><div><i><span class="" style="white-space:pre">            </span>a_z = surface_trg_vertices[:,0][:,2]</i></div>
<div><i><span class="" style="white-space:pre">           </span>b_x = surface_trg_vertices[:,1][:,0]</i></div><div><i><span class="" style="white-space:pre">            </span>b_y = surface_trg_vertices[:,1][:,1]</i></div><div><i><span class="" style="white-space:pre">            </span>b_z = surface_trg_vertices[:,1][:,2]</i></div>
<div><i><span class="" style="white-space:pre">           </span>c_x = surface_trg_vertices[:,2][:,0]</i></div><div><i><span class="" style="white-space:pre">            </span>c_y = surface_trg_vertices[:,2][:,1]</i></div><div><i><span class="" style="white-space:pre">            </span>c_z = surface_trg_vertices[:,2][:,2]</i></div>
<div><span class="" style="white-space:pre"><i>           </i></span></div><div><i><span class="" style="white-space:pre">                </span> #finds the sides lengths of the triangles (an array for each set of side)</i></div><div><i><span class="" style="white-space:pre">              </span>side_ab = ((a_x - b_x)**2.0 + (a_y - b_y)**2.0 + (a_z - b_z)**2.0)**0.5</i></div>
<div><i><span class="" style="white-space:pre">           </span>side_bc = ((b_x - c_x)**2.0 + (b_y - c_y)**2.0 + (b_z - c_z)**2.0)**0.5</i></div><div><i><span class="" style="white-space:pre">         </span>side_ca = ((c_x - a_x)**2.0 + (c_y - a_y)**2.0 + (c_z - a_z)**2.0)**0.5</i></div>
<div><span class="" style="white-space:pre"><i>           </i></span></div><div><i><span class="" style="white-space:pre">                </span> #computes the altitude of the triangles wrt the ab side</i></div><div><i><span class="" style="white-space:pre">                </span>s = 0.5 * (side_ab + side_bc + side_ca) #semiperimeter</i></div>
<div><i><span class="" style="white-space:pre">           </span>altitude_side_ab = (2.0 * (s * (s - side_ab) * (s - side_bc) * (s - side_ca))**0.5) / side_ab</i></div><div><span class="" style="white-space:pre"><i>           </i></span></div>
<div><i><span class="" style="white-space:pre">           </span> #computes the area of the triangles using ab sides and altitudes </i></div><div><i><span class="" style="white-space:pre">              </span>trg_surface_area = (side_ab * altitude_side_ab) / 2.0</i></div>
<div><span class="" style="white-space:pre"><i>           </i></span></div><div><i><span class="" style="white-space:pre">                </span> #computes the total surface area</i></div><div><i><span class="" style="white-space:pre">               </span>total_surface_area = np.sum(trg_surface_area)</i></div>
</div><div><br></div><div>Thanks,</div><div>                  Roberto</div><div><br></div></div>