{"id":13,"date":"2006-11-08T14:27:00","date_gmt":"2006-11-08T20:27:00","guid":{"rendered":"http:\/\/70.47.30.137\/~blockos\/blog\/?p=6"},"modified":"2010-06-27T20:58:04","modified_gmt":"2010-06-27T19:58:04","slug":"pluckermeister","status":"publish","type":"post","link":"https:\/\/blog.blockos.org\/?p=13","title":{"rendered":"Pl\u00fcckermeister"},"content":{"rendered":"<p>I replaced the <a href=\"http:\/\/citeseer.ist.psu.edu\/moller97fast.html\">M\u00f6ller<\/a> ray\/triangle intersection test by the one using <a href=\"http:\/\/www.loria.fr\/%7Elazard\/\/ARC-Visi3D\/Pant-project\/files\/plucker.html\">Pl\u00fccker<\/a> coordinates. It&#8217;s faster and more robust. The results is looking better (smoother normals). <strong>But<\/strong>, the holes didn&#8217;t disapear. After some investigations, i discovered that the problem came from point normals (I&#8217;m using them as point color). I read the objects from <a href=\"http:\/\/www.mpi-sb.mpg.de\/%7Eshin\/Research\/PLYformat\/PLYformat.html\">ply2<\/a> files which only store points and polygon indexes. Here&#8217;s how i&#8217;m computing point normals:<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">v is the mesh vertex list\r\nn is the mest point normal list\r\nforeach triangle t\r\n    t.n = normalize(cross(v[t.p1]-v[t.po],v[t.p2]-v[t.po]))\r\n    n[t.p0] += t.n\r\n    n[t.p1] += t.n\r\n    n[t.p2] += t.n\r\nnormalize each n<\/pre>\n<p>There&#8217;s a huge problem here. We are assuming that each polygon (triangle in this case) are ordered so that its normal is pointing away from the object. Unfortunately, this isn&#8217;t guaranteed by <a href=\"http:\/\/www.mpi-sb.mpg.de\/%7Eshin\/Research\/PLYformat\/PLYformat.html\">ply2<\/a> format. The following figure illustrates this.<\/p>\n<div style=\"text-align: center\"><img decoding=\"async\" alt=\"Mesh normal problem\" id=\"image32\" title=\"Mesh normal problem\" src=\"http:\/\/blog.blockos.org\/wp-content\/uploads\/2006\/11\/meshnormal.png\" \/><\/div>\n<p>Imagine if t0 and t1 are coplanar. If we are in the worst case, the normals of t0 and t1 are pointing in the opposite directions. As the normal at p is the sum of those two normals, it&#8217;ll be equal to the null vector. That explains the black holes. But that&#8217;s not all&#8230; The normal at the intersection point between the ray and the triangle is interpolated from the point normals of the triangle using barycentric coordinates. One of these 3 normals may be wrong or\/and, like the figure, they may be pointing in opposite directions&#8230; Arg!<\/p>\n<p>There&#8217;s no exact way to determine if a polygon normal is pointing away from the surface. So, unless the file format provides polygon (or in the best case) points normals, i&#8217;ll not interpolate point normals.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I replaced the M\u00f6ller ray\/triangle intersection test by the one using Pl\u00fccker coordinates. It&#8217;s faster and more robust. The results is looking better (smoother normals). But, the holes didn&#8217;t disapear. After some investigations, i discovered that the problem came from point normals (I&#8217;m using them as point color). I read\u2026 <a class=\"continue-reading-link\" href=\"https:\/\/blog.blockos.org\/?p=13\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4],"tags":[27,28,15],"_links":{"self":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/13"}],"collection":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13"}],"version-history":[{"count":2,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions"}],"predecessor-version":[{"id":147,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=\/wp\/v2\/posts\/13\/revisions\/147"}],"wp:attachment":[{"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.blockos.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}