'Why CGAL:intersection() fails to detect the intersection point between a Line_3 and a Segment_3?
I want to detect the intersection point between an infinite line and a line segment. My code is as follows:
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Line_3.h>
#include <CGAL/Plane_3.h>
#include <CGAL/Point_3.h>
#include <CGAL/Segment_3.h>
#include <CGAL/intersections.h>
#include <algorithm>
#include <iostream>
#include <vector>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::Point_3 Point_3;
typedef K::Segment_3 Segment_3;
typedef K::Plane_3 Plane_3;
typedef K::Line_3 Line_3;
using namespace std;
int main()
{
Point_3 f1o{-22.7364, -1.91511, 13.9913};
Point_3 f2o{-25.5079, 1.00557, 28.6024};
Segment_3 segss{f1o, f2o};
Point_3 as1{82.2128, 38.6563, 18.2210};
Point_3 as2{-105.8106, -27.1731, 35.9316};
Line_3 Inf_Line{as1, as2};
auto result2 = CGAL::intersection(Inf_Line, segss);
if (result2)
{
cout << "there is an intersection\n";
}
else
{
cout << "no intersection\n";
}
exit(0);
};
And I finally got no intersection. I've used matlab script to visualize the two lines. I am sure they are intersected.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
