3 bool do3DLinesIntersect(
const std::vector<Line::FitLine2D>& linesA,
const std::vector<Line::FitLine2D>& linesB) {
4 std::vector<Vector3D> intersectionPointsA;
5 std::vector<Vector3D> intersectionPointsB;
8 for (
size_t i = 0; i < 3; ++i) {
9 IntersectionResult res = findIntersection(linesA[i], linesB[i]);
11 if (!res.intersects && !res.areCoincident)
return false;
15 intersectionPointsA.push_back(
Vector3D(res.point.x, res.point.y, 0));
16 intersectionPointsB.push_back(
Vector3D(res.point.x, res.point.y, 0));
18 intersectionPointsA.push_back(
Vector3D(res.point.x, 0, res.point.y));
19 intersectionPointsB.push_back(
Vector3D(res.point.x, 0, res.point.y));
21 intersectionPointsA.push_back(
Vector3D(0, res.point.x, res.point.y));
22 intersectionPointsB.push_back(
Vector3D(0, res.point.x, res.point.y));
27 for (
size_t i = 0; i < 3; ++i) {
28 double dist =
distance3D(intersectionPointsA[i], intersectionPointsB[i]);
29 if (dist > INTERSECTION_DISTANCE_THRESHOLD)
return false;
33 Line3D line3DA = convertTo3DLine(linesA);
34 Line3D line3DB = convertTo3DLine(linesB);
38 return perpendicularDistance <= PERPENDICULAR_DISTANCE_THRESHOLD;
42 return sqrt((a.
x - b.
x) * (a.
x - b.
x) + (a.
y - b.
y) * (a.
y - b.
y) + (a.
z - b.
z) * (a.
z - b.
z));
Definition: Line3DCompare.h:6
double x
Definition: Line3DCompare.h:7
double z
Definition: Line3DCompare.h:7
double y
Definition: Line3DCompare.h:7
double distance3D(const Vector3D &a, const Vector3D &b)
Definition: test_code.h:41
double distanceBetween3DLines(const Line3D &lineA, const Line3D &lineB)
Definition: test_code.h:45
bool do3DLinesIntersect(const std::vector< Line::FitLine2D > &linesA, const std::vector< Line::FitLine2D > &linesB)
Definition: test_code.h:3