Functions: interpolate brackets and spacing

This commit is contained in:
Matthias Grob
2022-11-21 18:38:29 +01:00
committed by Daniel Agar
parent c7a8589afc
commit 9de3af1cbc
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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;
}
}
+1 -1
View File
@@ -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);
}