From 4b2392e44ad08d6a923ecc66bf8d6c13f81f8481 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Sat, 18 Aug 2018 15:11:54 +0200 Subject: [PATCH] catmull-rom: make curves more rounded See https://github.com/Beep6581/RawTherapee/pull/4701#issuecomment-414054187 --- rtengine/diagonalcurves.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rtengine/diagonalcurves.cc b/rtengine/diagonalcurves.cc index 1af086925..f478ba719 100644 --- a/rtengine/diagonalcurves.cc +++ b/rtengine/diagonalcurves.cc @@ -289,7 +289,8 @@ inline double catmull_rom_tj(double ti, double xi, double yi, double xj, double yj) { - static constexpr double alpha = 0.5; + // see https://github.com/Beep6581/RawTherapee/pull/4701#issuecomment-414054187 + static constexpr double alpha = 0.375; return pow(sqrt(pow2(xj-xi) + pow2(yj-yi)), alpha) + ti; } @@ -374,10 +375,19 @@ inline void catmull_rom_spline(int n_points, inline void catmull_rom_reflect(double px, double py, double cx, double cy, double &rx, double &ry) { +#if 0 double dx = px - cx; double dy = py - cy; rx = cx - dx; ry = cy - dy; +#else + // see https://github.com/Beep6581/RawTherapee/pull/4701#issuecomment-414054187 + static constexpr double epsilon = 1e-5; + double dx = px - cx; + double dy = py - cy; + rx = cx - dx * 0.01; + ry = dx > epsilon ? (dy / dx) * (rx - cx) + cy : cy; +#endif }