Skip to content

Commit a8d883c

Browse files
committed
Make tolerance non configurable, use forward declare
1 parent a9a83ae commit a8d883c

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

include/RaidZeroLib/api/Geometry/Point.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include "RaidZeroLib/api/Geometry/Rotation.hpp"
2+
#include "au/au.hpp"
33
#include <optional>
44

55
namespace rz {
@@ -44,7 +44,7 @@ class Point {
4444

4545
Point rotateBy(const Rotation& rhs) const noexcept;
4646

47-
bool isApprox(const Point& rhs, au::QuantityD<au::Meters> tol = au::meters(1e-12)) const noexcept;
47+
bool isApprox(const Point& rhs) const noexcept;
4848

4949
private:
5050
au::QuantityD<au::Meters> x = au::ZERO;

include/RaidZeroLib/api/Geometry/Rotation.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class Rotation {
1111

1212
Rotation(au::QuantityD<au::Meters> x, au::QuantityD<au::Meters> y) noexcept;
1313

14+
Rotation(double x, double y) noexcept;
15+
1416
au::QuantityD<au::Radians> Theta() const noexcept;
1517

1618
double Sin() const noexcept;
@@ -29,7 +31,7 @@ class Rotation {
2931

3032
Rotation operator/(double scalar) const noexcept;
3133

32-
bool isApprox(const Rotation& rhs, au::QuantityD<au::Radians> tol = au::radians(1e-12)) const noexcept;
34+
bool isApprox(const Rotation& rhs) const noexcept;
3335

3436
private:
3537
au::QuantityD<au::Radians> theta = au::ZERO;

src/RaidZeroLib/api/Geometry/Point.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "RaidZeroLib/api/Geometry/Point.hpp"
22
#include "RaidZeroLib/api/Utility/Math.hpp"
3+
#include "RaidZeroLib/api/Geometry/Rotation.hpp"
34

45
namespace rz {
56

@@ -75,8 +76,8 @@ Point Point::rotateBy(const Rotation& rhs) const noexcept {
7576
return Point(x * c - y * s, x * s + y * c);
7677
}
7778

78-
bool Point::isApprox(const Point& rhs, au::QuantityD<au::Meters> tol) const noexcept {
79-
return this->distTo(rhs) <= tol;
79+
bool Point::isApprox(const Point& rhs) const noexcept {
80+
return this->distTo(rhs) <= au::meters(1e-9);
8081
}
8182

8283
au::QuantityD<au::Meters> circumradius(const Point& A, const Point& B, const Point& C) noexcept {

src/RaidZeroLib/api/Geometry/Rotation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Rotation::Rotation(au::QuantityD<au::Radians> theta) noexcept : theta(constrainA
88
Rotation::Rotation(au::QuantityD<au::Meters> x, au::QuantityD<au::Meters> y) noexcept
99
: theta(x == au::ZERO && y == au::ZERO ? au::ZERO : au::arctan2(y, x)){}
1010

11+
Rotation::Rotation(double x, double y) noexcept
12+
: theta(x == 0 && y == 0 ? au::ZERO : au::radians(std::atan2(y, x))){}
13+
1114
au::QuantityD<au::Radians> Rotation::Theta() const noexcept {
1215
return theta;
1316
}
@@ -44,9 +47,9 @@ Rotation Rotation::operator/(double scalar) const noexcept {
4447
return *this * (1.0 / scalar);
4548
}
4649

47-
bool Rotation::isApprox(const Rotation& rhs, au::QuantityD<au::Radians> tol) const noexcept {
50+
bool Rotation::isApprox(const Rotation& rhs) const noexcept {
4851
const auto diff = constrainAngle180(theta - rhs.theta);
49-
return au::abs(diff) <= tol;
52+
return au::abs(diff) <= au::radians(1e-9);
5053
}
5154

5255
} // namespace rz

test/test/Geometry/PointTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "RaidZeroLib/api/Geometry/Point.hpp"
2+
#include "RaidZeroLib/api/Geometry/Rotation.hpp"
23
#include <cmath>
34
#include <gtest/gtest.h>
45

0 commit comments

Comments
 (0)