From 9577bd535a18be9c3348f63ebaf434e1f14b8bcd Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 22 May 2016 16:47:38 +0200 Subject: Introduce `imgen::vector` tuple alias, generate metrics as double --- unit_circle.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'unit_circle.cc') diff --git a/unit_circle.cc b/unit_circle.cc index 283fb53..aa12bf7 100644 --- a/unit_circle.cc +++ b/unit_circle.cc @@ -4,13 +4,12 @@ #include #include -int p_norm(double p, int x, int y) { - return static_cast(std::nearbyint( - std::pow( - std::pow(std::abs(x), p) + std::pow(std::abs(y), p), - 1.0 / p - ) - )); +double p_norm(double p, int x, int y) { + return std::pow( + std::pow(std::abs(x), p) + + std::pow(std::abs(y), p), + 1.0 / p + ); } void generate_p_unit_circle( @@ -24,7 +23,7 @@ void generate_p_unit_circle( 128, 128, [p](std::ptrdiff_t x, std::ptrdiff_t y) -> imgen::color { - if ( p_norm(p, x, y) <= 32 ) { + if ( p_norm(p, x, y) <= 32.0 ) { return imgen::black(); } else { return imgen::white(); -- cgit v1.2.3