Skip to content

Commit

Permalink
feat(geometry): adding arcAngle function in Geometry::Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslimacodes committed Jan 26, 2024
1 parent 4116161 commit 1df9265
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/Armorial/Geometry/Arc/Arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ namespace Geometry {
*/
[[nodiscard]] bool pointInArc(const Vector2D &point) const;

/*!
* \return The absolute angle of an arc.
*/
[[nodiscard]] float arcAngle() const;

/*!
* \brief Compute the points at which a given LineSegment intersects this Arc instance, if these points exists.
* \param lineSegment The given LineSegment instance.
Expand Down
5 changes: 5 additions & 0 deletions src/Armorial/Geometry/Arc/Arc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ bool Arc::pointInArc(const Vector2D &point) const {
return (angleWithinArc(normPoint.angle()) && (normPoint.length() <= radius()));
}

float Arc::arcAngle() const{
float startAngle = (_startAngle.value() < 0) ? _startAngle.value() + M_PI*2 : _startAngle.value();
float endAngle = (_endAngle.value() < 0) ? _endAngle.value() + M_PI*2 : _endAngle.value();
return std::abs(startAngle - endAngle);
}
std::vector<Vector2D> Arc::intersectionWithLine(const LineSegment &lineSegment) const {
std::vector<Vector2D> intersections;

Expand Down

0 comments on commit 1df9265

Please sign in to comment.