diff options
author | Adrian Kummerlaender | 2016-05-22 16:47:38 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2016-05-22 16:47:38 +0200 |
commit | 9577bd535a18be9c3348f63ebaf434e1f14b8bcd (patch) | |
tree | 6033baebe85679d623eec5bcbb16f8f06cedc248 /unit_circle.cc | |
parent | e565d4e44c8013607a372c0f2a4af0eee8164843 (diff) | |
download | voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.tar voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.tar.gz voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.tar.bz2 voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.tar.lz voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.tar.xz voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.tar.zst voronoi-9577bd535a18be9c3348f63ebaf434e1f14b8bcd.zip |
Introduce `imgen::vector` tuple alias, generate metrics as double
Diffstat (limited to 'unit_circle.cc')
-rw-r--r-- | unit_circle.cc | 15 |
1 files changed, 7 insertions, 8 deletions
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 <vector> #include <algorithm> -int p_norm(double p, int x, int y) { - return static_cast<int>(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(); |