mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-20 11:23:06 +08:00
Functions: interpolate brackets and spacing
This commit is contained in:
committed by
Daniel Agar
parent
c7a8589afc
commit
9de3af1cbc
@@ -160,8 +160,8 @@ const T interpolate(const T &value, const T &x_low, const T &x_high, const T &y_
|
||||
} else {
|
||||
/* linear function between the two points */
|
||||
T a = (y_high - y_low) / (x_high - x_low);
|
||||
T b = y_low - a * x_low;
|
||||
return a * value + b;
|
||||
T b = y_low - (a * x_low);
|
||||
return (a * value) + b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ TEST(FunctionsTest, interpolate)
|
||||
// corner case when y_low > y_high
|
||||
EXPECT_FLOAT_EQ(interpolate(1.5f, 1.f, 2.f, 6.f, 4.f), 5.f);
|
||||
|
||||
// corner case when x_low == x_high == y_low == y_high == 0.f
|
||||
// corner case when x_low == x_high == y_low == y_high == 0.f
|
||||
EXPECT_FLOAT_EQ(interpolate(0.f, 0.f, 0.f, 0.f, 0.f), 0.f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user