diff --git a/include/Armorial/Geometry/Arc/Arc.h b/include/Armorial/Geometry/Arc/Arc.h index d8eac51..b8aa39f 100644 --- a/include/Armorial/Geometry/Arc/Arc.h +++ b/include/Armorial/Geometry/Arc/Arc.h @@ -72,9 +72,10 @@ namespace Geometry { /*! * \brief Checks if a given point is contained in this Arc. * \param point The given point. + * \param error The error used to consider points in outskirts of the arc * \return True if the point is contained in this Arc and False otherwise. */ - [[nodiscard]] bool pointInArc(const Vector2D &point) const; + [[nodiscard]] bool pointInArc(const Vector2D &point, float error = 0.0f) const; /*! * \return The absolute angle of an arc. diff --git a/src/Armorial/Geometry/Arc/Arc.cpp b/src/Armorial/Geometry/Arc/Arc.cpp index b2947bc..e61caa4 100644 --- a/src/Armorial/Geometry/Arc/Arc.cpp +++ b/src/Armorial/Geometry/Arc/Arc.cpp @@ -70,13 +70,13 @@ bool Arc::angleWithinArc(const Geometry::Angle &angle) const { } } -bool Arc::pointInArc(const Vector2D &point) const { +bool Arc::pointInArc(const Vector2D &point, float error) const { Vector2D normPoint = point - center(); - return (angleWithinArc(normPoint.angle()) && (normPoint.length() <= radius())); + return (angleWithinArc(normPoint.angle()) && (normPoint.length() <= (radius() + error))); } float Arc::arcAngle() const{ - float temp = _endAngle.value() - _startAngle.value(); + float temp = endAngle().value() - startAngle().value(); if(temp < 0){ temp+=M_PI*2; } @@ -92,7 +92,8 @@ std::vector Arc::intersectionWithLine(const LineSegment &lineSegment) // For each point in the intersection result, check if it is contained in the arc // and put it into the vector if True for(auto p : intersectionsWithCircle) { - if(pointInArc(p)) { + // Vector2D newP = (p - _center) * 0.9 + _center; // decreasing p radius in order to fit properly in pointInArc() function + if(pointInArc(p, 0.01f)) { intersections.push_back(p); } }