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.
This commit is contained in:
parent
2226fb32af
commit
85e38a358d
|
@ -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.
|
||||
|
|
Reference in a new issue