u02/tests: Use floats for r/d in circle prop test

It does not improve the test’s accuracy, but it seems weird to first
convert the radius to an int and then save the distance as a double.
filtered
Simon Bruder 2023-05-10 20:47:08 +02:00
parent 2226fb32af
commit 85e38a358d
1 changed files with 2 additions and 2 deletions

View File

@ -352,7 +352,7 @@ TEST_CASE("Bresenham circle (prop: √(x²+y²)-r<ε)") {
SKIP("All coordinates have extreme value, skipping (avoid rounding error)");
}
const int r =
const float r =
round(std::sqrt(std::pow((x1 - x0), 2) + std::pow((y1 - y0), 2)));
canvas_buffer *canvas = new canvas_buffer(size, size);
@ -363,7 +363,7 @@ TEST_CASE("Bresenham circle (prop: √(x²+y²)-r<ε)") {
bool pass = true;
for (int x = 0; x < size; x++) {
for (int y = 0; y < size; y++) {
double distance =
float distance =
std::abs(std::sqrt(std::pow(x0 - x, 2) + std::pow(y0 - y, 2)) - r);
// Because of rounding errors, an exact test (for all pixels) is not
// feasible.