Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Wrong unit normal with CGAL::unit_normal

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Wrong unit normal with CGAL::unit_normal


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] Wrong unit normal with CGAL::unit_normal
  • Date: Mon, 12 Sep 2016 11:07:30 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:+Np9KR1NW6cNb+5GsmDT+DRfVm0co7zxezQtwd8ZsegeLvad9pjvdHbS+e9qxAeQG96KsrQa1KGN6vioGTRZp83Q6DZaKN0EfiRGoP1epxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJLL+j4UrTfk96wn7jrvcaCOkMW23HmOOs6bE3v616A7o9O2coqA51y4yOBmmFPdeVSyDEgDnOotDG42P2N+oV++T9bofMr+p0Ie6z7e6MlUe4QV2x+YChmrPHs4BLMRA/K6noHWXgNiTJJBRLE5Vf0RMTfqCz/46BG1SOTJtH3QLZ8fTO47qB3AF/HhSACOiIj4U/egdB3lrMa6lr1vBh42Y/TfMeQMNJxe6rceZURQm8XDZUZbDBIHo7pN9hHNOEGJ+sN94Q=
  • Organization: GeometryFactory

I tried the following:

include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <iostream>
#include <vector>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

int main()
{
K::Point_3 p1(-119.452959304302,54.727712609640498,888);
K::Point_3 p2(-119.27352872835201,54.731184848162897,820);
K::Point_3 p3(-119.369047730614,55.029360094556502,678);

K::Vector_3 v = CGAL::unit_normal(p1, p2, p3);

std::cout << v * v << std::endl;
}


and 1 is displayed.

Sebastien.

On 09/12/2016 12:52 AM, chrism wrote:
I have a set of points in UTM and lat/long coordinates that represent the
vertices of a triangle mesh located on the surface of the earth. I need to
calculate a unit normal to this triangle, and so use the CGAL::unit_normal
function.

With UTM coordinates this works as expected.

With lat/long/elevation the wrong answer is produced:

(-119.452959304302,54.727712609640498,888)
(-119.27352872835201,54.731184848162897,820)
(-119.369047730614,55.029360094556502,678)

If I scale the x,y by 100 000, it then works correctly:

(-11945295.9304302,5472771.26096405,888)
(-11927352.8728352,5473118.4848162895,820)
(-11936904.7730614,5502936.0094556501,678)

Strangely: without this scaling, paraview is unable to render the mesh
properly (same issue?).

If I plot these point sets in Wolfram Alpha, the problem is apparent: the
non-scaled produces a plane that is vertical instead of horizontal.

works
https://www.wolframalpha.com/input/?i=plane+through+(-11945295.9304302,5472771.26096405,888)+(-11927352.8728352,5473118.4848162895,820)+(-11936904.7730614,5502936.0094556501,678)
broken
https://www.wolframalpha.com/input/?i=plane+through+(-119.452959304302,54.727712609640498,888)+(-119.27352872835201,54.731184848162897,820)+(-119.369047730614,55.029360094556502,678)

I am using an Exact_predicates_inexact_constructions_kernel.

I have tried with the exact constructions, but it doesn't seem to allow me
to use it alongside the inexact?When I call the unit_normal function, I get

/usr/include/CGAL/Kernel/function_objects.h:1879:17: error: no match for
‘operator/’ (operand types are
‘CGAL::CommonKernelFunctors::Construct_unit_normal_3<CGAL::Simple_cartesian&lt;CGAL::Gmpq>
::Vector_3 {aka CGAL::Vector_3<CGAL::Simple_cartesian&lt;CGAL::Gmpq> >}’
and ‘CGAL::Null_functor::result_type {aka CGAL::Null_tag}’)
res = res / CGAL::sqrt(res.squared_length());

Any ideas what is causing the unit normal to be so incorrect? I'm guessing a
numeric issue, but I'm not really sure where? Is there a way around this?
It's a one off computation so can take the hit of exact constructions if
that a) solves it and b) is used along side the inexact.



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Wrong-unit-normal-with-CGAL-unit-normal-tp4662261.html
Sent from the cgal-discuss mailing list archive at Nabble.com.





Archive powered by MHonArc 2.6.18.

Top of Page