Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/common/math/math_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ double RandomDouble(const double s, const double t, unsigned int rand_seed) {
return s + (t - s) / 16383.0 * (rand_r(&rand_seed) & 16383);
}

int double_compare(const double d1, const double d2, const double epsilon) {
int DoubleCompare(const double d1, const double d2, const double epsilon) {
DCHECK(!std::isnan(d1));
DCHECK(!std::isnan(d2));

Expand Down
2 changes: 1 addition & 1 deletion modules/common/math/math_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ T Clamp(const T value, T bound1, T bound2) {
return value;
}

int double_compare(
int DoubleCompare(
const double d1, const double d2,
const double epsilon = std::numeric_limits<double>::epsilon());

Expand Down
18 changes: 9 additions & 9 deletions modules/common/math/math_utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@ TEST(MathUtilsTest, Square) {
}

TEST(MathUtilsTest, Double) {
EXPECT_EQ(double_compare(234.32, 93.9), 1);
EXPECT_EQ(double_compare({234.32}, {93.9}), 1);
EXPECT_EQ(double_compare(234.32, 93.9, 1e-5), 1);
EXPECT_EQ(double_compare({234.32}, {93.9}, 1e-5), 1);
EXPECT_EQ(DoubleCompare(234.32, 93.9), 1);
EXPECT_EQ(DoubleCompare({234.32}, {93.9}), 1);
EXPECT_EQ(DoubleCompare(234.32, 93.9, 1e-5), 1);
EXPECT_EQ(DoubleCompare({234.32}, {93.9}, 1e-5), 1);

EXPECT_EQ(double_compare(23.32, 93.9), -1);
EXPECT_EQ(double_compare(4.32, 4.32), 0);
EXPECT_EQ(double_compare(2.1, 2.0009, 1e-5), 1);
EXPECT_EQ(double_compare(1.1, 2.0009, 1e-5), -1);
EXPECT_EQ(double_compare(2.1, 2.0009, 1), 0);
EXPECT_EQ(DoubleCompare(23.32, 93.9), -1);
EXPECT_EQ(DoubleCompare(4.32, 4.32), 0);
EXPECT_EQ(DoubleCompare(2.1, 2.0009, 1e-5), 1);
EXPECT_EQ(DoubleCompare(1.1, 2.0009, 1e-5), -1);
EXPECT_EQ(DoubleCompare(2.1, 2.0009, 1), 0);
}

} // namespace math
Expand Down
4 changes: 2 additions & 2 deletions modules/control/common/trajectory_analyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ PathPoint TrajectoryAnalyzer::QueryMatchedPathPoint(const double x,
index_min + 1 == trajectory_points_.size() ? index_min : index_min + 1;

if (index_start == index_end ||
common::math::double_compare(trajectory_points_[index_start].s,
trajectory_points_[index_end].s) == 0) {
common::math::DoubleCompare(trajectory_points_[index_start].s,
trajectory_points_[index_end].s) == 0) {
return trajectory_points_[index_start];
}

Expand Down