Skip to content

Commit 5cba1e4

Browse files
committed
Extracted deg2rad to common/math.h, updated conversions
1 parent ce85f13 commit 5cba1e4

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

src/common/math.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,11 @@ static inline void dt_vector_sin(const dt_aligned_pixel_t arg,
749749
sine[c] = scaled[c] * (p[c] * (abs_scaled[c] - one[c]) + one[c]);
750750
}
751751

752+
inline float deg2rad(const float degrees)
753+
{
754+
return degrees * M_PI_F / 180.f;
755+
}
756+
752757
// clang-format off
753758
// modelines: These editor modelines have been set for all relevant files by tools/update_modelines.py
754759
// vim: shiftwidth=2 expandtab tabstop=2 cindent

src/iop/agx.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,11 +2163,6 @@ void gui_init(dt_iop_module_t *self)
21632163
gui_update(self);
21642164
}
21652165

2166-
static float _degrees_to_radians(const float degrees)
2167-
{
2168-
return degrees * M_PI_F / 180.f;
2169-
}
2170-
21712166
static void _set_neutral_params(dt_iop_agx_user_params_t *user_params)
21722167
{
21732168
user_params->look_slope = 1.0f;
@@ -2277,15 +2272,15 @@ void init_presets(dt_iop_module_so_t *self)
22772272
user_params.red_inset = 0.1f;
22782273
user_params.green_inset = 0.1f;
22792274
user_params.blue_inset = 0.15f;
2280-
user_params.red_rotation = _degrees_to_radians(2.f);
2281-
user_params.green_rotation = _degrees_to_radians(-1.f);
2282-
user_params.blue_rotation = _degrees_to_radians(-3.f);
2275+
user_params.red_rotation = deg2rad(2.f);
2276+
user_params.green_rotation = deg2rad(-1.f);
2277+
user_params.blue_rotation = deg2rad(-3.f);
22832278
user_params.red_outset = 0.1f;
22842279
user_params.green_outset = 0.1f;
22852280
user_params.blue_outset = 0.15f;
2286-
user_params.red_unrotation = _degrees_to_radians(2.f);
2287-
user_params.green_unrotation = _degrees_to_radians(-1.f);
2288-
user_params.blue_unrotation = _degrees_to_radians(-3.f);
2281+
user_params.red_unrotation = deg2rad(2.f);
2282+
user_params.green_unrotation = deg2rad(-1.f);
2283+
user_params.blue_unrotation = deg2rad(-3.f);
22892284
// Don't restore purity - try to avoid posterization.
22902285
user_params.master_outset_ratio = 0.0f;
22912286
user_params.master_unrotation_ratio = 1.0f;

src/iop/colorequal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void _mean_gaussian(float *const buf,
454454
#define ANGLE_SHIFT +20.f
455455
static inline float _deg_to_rad(const float angle)
456456
{
457-
return (angle + ANGLE_SHIFT) * M_PI_F / 180.f;
457+
return deg2rad(angle + ANGLE_SHIFT);
458458
}
459459

460460
/* We use precalculated data for the logistic weighting function for performance and stability
@@ -1723,7 +1723,7 @@ static inline void _periodic_RBF_interpolate(float nodes[NODES],
17231723
// every degree. We use un-offset angles here, since thue hue
17241724
// offset is merely a GUI thing, only relevant for user-defined
17251725
// nodes.
1726-
const float hue = (float)i * 360.0f / (float)LUT_ELEM * M_PI_F / 180.f - M_PI_F;
1726+
const float hue = deg2rad((float)i * 360.0f / (float)LUT_ELEM) - M_PI_F;
17271727
LUT[i] = 0.f;
17281728

17291729
for(int k = 0; k < NODES; k++)

src/iop/sigmoid.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,6 @@ void init_presets(dt_iop_module_so_t *self)
272272
self->version(), &p, sizeof(p), 1,
273273
DEVELOP_BLEND_CS_RGB_SCENE);
274274

275-
const float DEG_TO_RAD = M_PI_F / 180.f;
276-
277275
// smooth - a preset that utilizes the primaries feature
278276
p.middle_grey_contrast = 1.5f;
279277
// Allow a little bit more room for the highlights
@@ -284,9 +282,9 @@ void init_presets(dt_iop_module_so_t *self)
284282
p.red_inset = 0.1f;
285283
p.green_inset = 0.1f;
286284
p.blue_inset = 0.15f;
287-
p.red_rotation = 2.f * DEG_TO_RAD;
288-
p.green_rotation = -1.f * DEG_TO_RAD;
289-
p.blue_rotation = -3.f * DEG_TO_RAD;
285+
p.red_rotation = deg2rad(2.f);
286+
p.green_rotation = deg2rad(-1.f);
287+
p.blue_rotation = deg2rad(-3.f);
290288
// Don't restore purity - try to avoid posterization.
291289
p.purity = 0.f;
292290
// Constant base primaries (not dependent on work profile) to

0 commit comments

Comments
 (0)