Bug with the plane function has_on?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug with the plane function has_on?

xiaojin
This post was updated on .
In my program, I have

#include <CGAL/Simple_cartesian.h>
typedef CGAL::Simple_cartesian<double> K;
typedef K::FT FT;
typedef K::Ray_3 Ray;
typedef K::Line_3 Line;
typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
typedef K::Triangle_3 Triangle;
typedef K::Plane_3 Plane;
#include <QMainWindow>
int main(int argc, char *argv[])
{
    Point p0(0.103835, -0.0921626, -2.2133);
    Point p1(0.165068, -0.0411001, -2.28194);
    Point p2(0.0954547, -0.0170658, -2.23422);
    Plane plane(p0, p1, p2);
    std::cout << plane.has_on(p0) << std::endl;
    std::cout << plane.has_on(p1) << std::endl;
    std::cout << plane.has_on(p2) << std::endl;
}

the result is
0
1
1

but the correct result should be:
1
1
1

And is I change the Kernel K as

typedef CGAL::Simple_cartesian<float> K

the result is correct.


And if I change the Kernel K as

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;

Then output:
0
0
0

So what's the problem? Is there a bug?





--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Bug with the plane function has_on?

Sebastien Loriot (GeometryFactory)
You have to use a kernel with exact predicates like
CGAL::Exact_predicates_inexact_constructions_kernel instead of
CGAL::Simple_cartesian<double>.

More details why here:

https://www.cgal.org/FAQ.html#inexact_NT

Sebastien.


On 4/1/20 6:11 PM, xiaojin wrote:

> In my program, I have
>
> #include <CGAL/Simple_cartesian.h>
> typedef CGAL::Simple_cartesian<double> K;
> typedef K::FT FT;
> typedef K::Ray_3 Ray;
> typedef K::Line_3 Line;
> typedef K::Point_3 Point;
> typedef K::Segment_3 Segment;
> typedef K::Triangle_3 Triangle;
> typedef K::Plane_3 Plane;
> #include <QMainWindow>
> int main(int argc, char *argv[])
> {
>      Point p0(0.103835, -0.0921626, -2.2133);
>      Point p1(0.165068, -0.0411001, -2.28194);
>      Point p2(0.0954547, -0.0170658, -2.23422);
>      Plane plane(p0, p1, p2);
>      std::cout << plane.has_on(p0) << std::endl;
>      std::cout << plane.has_on(p1) << std::endl;
>      std::cout << plane.has_on(p2) << std::endl;
> }
>
> the result is
> 0
> 1
> 1
>
> but the correct result should be:
> 1
> 1
> 1
>
> And is I change the Kernel K as
>
> typedef CGAL::Simple_cartesian<float> K
>
> the result is correct.
>
> So what's the problem? Is there a bug?
>
>
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Bug with the plane function has_on?

xiaojin
I have used Exact_predicates_inexact_constructions_kernel, but it still
incorrect, what can I do to solve this problem?



--
Sent from: http://cgal-discuss.949826.n4.nabble.com/

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss


Reply | Threaded
Open this post in threaded view
|

Re: Bug with the plane function has_on?

Sebastien Loriot (GeometryFactory)
Sorry I only looked at your kernel type. Here you also need exact
construction as internally the plane equation is computed.

CGAL::Exact_predicates_exact_constructions_kernel should be used for
example.

Sebastien.

On 4/1/20 6:39 PM, xiaojin wrote:
> I have used Exact_predicates_inexact_constructions_kernel, but it still
> incorrect, what can I do to solve this problem?
>
>
>
> --
> Sent from: http://cgal-discuss.949826.n4.nabble.com/
>

--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss