HighMap library (C++)
Loading...
Searching...
No Matches
range.hpp
Go to the documentation of this file.
1/* Copyright (c) 2023 Otto Link. Distributed under the terms of the GNU General
2 Public License. The full license is in the file LICENSE, distributed with
3 this software. */
4
17#pragma once
18
19#include "highmap/array.hpp"
21
22namespace hmap
23{
24
32
52void chop(Array &array, float vmin);
53
76void chop_max_smooth(Array &array, float vmax);
77
98void clamp(Array &array, float vmin = 0.f, float vmax = 1.f);
99
123void clamp(Array &array, float vmax, ClampMode mode);
124
136void clamp_min(Array &array, float vmin);
137
139void clamp_min(Array &array, const Array &vmin);
140
152void clamp_min_smooth(Array &array, float vmin, float k = 0.2f);
153
155void clamp_min_smooth(Array &array, const Array &vmin, float k = 0.2f);
156
170float clamp_min_smooth(float x, float vmin, float k = 0.2f);
171
183void clamp_max(Array &array, float vmax);
184
186void clamp_max(Array &array, const Array &vmax);
187
199void clamp_max_smooth(Array &array, float vmax, float k = 0.2f);
200
202void clamp_max_smooth(Array &array, const Array &vmax, float k = 0.2f);
203
226void clamp_oblique_plane(Array &array,
227 float vmax,
228 float angle,
229 float slope,
230 bool use_max_operator = true, // min if not
231 float k = 0.f,
232 glm::vec2 center = {0.5f, 0.5f},
233 const BBox2D &bbox = BBox2D::unit());
234
249void clamp_smooth(Array &array, float vmin, float vmax, float k = 0.2f);
250
262Array maximum(const Array &array1, const Array &array2);
263
275
277Array maximum(const Array &array1, const float value);
278
307Array maximum_smooth(const Array &array1, const Array &array2, float k = 0.2);
308
334
336float maximum_smooth(const float a, const float b, float k = 0.2);
337
349Array minimum(const Array &array1, const Array &array2);
350
362
364Array minimum(const Array &array1, const float value);
365
384Array minimum_smooth(const Array &array1, const Array &array2, float k = 0.2);
385
400
402float minimum_smooth(const float a, const float b, float k);
403
423void remap(Array &array,
424 float vmin,
425 float vmax,
426 float from_min,
427 float from_max);
428
444
446void remap(Array &array,
447 float vmin = 0,
448 float vmax = 1,
450
465void rescale(Array &array, float scaling, float vref = 0.f);
466
482void normalize_and_clip(Array &array,
483 float multiplier = 2.5f,
484 bool smooth_transition = true,
485 bool range_01 = false,
487
488} // namespace hmap
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Axis-aligned 2D bounding box in world coordinates.
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
Abstract communicator interface providing MPI-style collective directives for single-source SPMD Arra...
Definition communicator_interface.hpp:60
static SingleArrayComm & instance()
Definition communicator.cpp:78
Definition opencv.hpp:20
void chop_max_smooth(Array &array, float vmax)
Set to zero any value lower than vmax and apply a linear decrease slope between vmax / 2 and vmax.
Definition range.cpp:29
void remap(Array &array, float vmin, float vmax, float from_min, float from_max)
Remap array elements from a starting range to a target range.
Definition range.cpp:434
void clamp_min(Array &array, float vmin)
Clamp array values lower than a given bound.
Definition range.cpp:155
void clamp_min_smooth(Array &array, float vmin, float k=0.2f)
Clamp array values lower than a given bound with a smooth transition.
Definition range.cpp:180
Array minimum_smooth(const Array &array1, const Array &array2, float k=0.2)
Return the polynomial cubic smooth element-wise minimum of two arrays.
Definition range.cpp:381
void clamp_smooth(Array &array, float vmin, float vmax, float k=0.2f)
Clamp array values within a given interval with a smooth transition.
Definition range.cpp:269
void clamp_max_smooth(Array &array, float vmax, float k=0.2f)
Clamp array values larger than a given bound with a smooth transition.
Definition range.cpp:112
Array maximum_smooth(const Array &array1, const Array &array2, float k=0.2)
Return the polynomial cubic smooth element-wise maximum of two arrays.
Definition range.cpp:323
Array maximum(const Array &array1, const Array &array2)
Return the element-wise maximum of two arrays.
Definition range.cpp:297
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65
void chop(Array &array, float vmin)
Set to zero any value lower than vmin.
Definition range.cpp:17
Array slope(glm::ivec2 shape, float angle, float slope, const Array *p_ctrl_param=nullptr, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit())
Return an array corresponding to a slope with a given overall.
Definition primitives.cpp:362
void rescale(Array &array, float scaling, float vref=0.f)
Remap array elements from a starting range to a target range.
Definition range.cpp:458
void normalize_and_clip(Array &array, float multiplier=2.5f, bool smooth_transition=true, bool range_01=false, ICommunicator &comm=SingleArrayComm::instance())
Normalize an array around its mean and clip values.
Definition range.cpp:476
ClampMode
Definition range.hpp:26
@ NEGATIVE_ONLY
Definition range.hpp:28
@ POSITIVE_ONLY
Definition range.hpp:27
@ NONE
Definition range.hpp:30
@ BOTH
Definition range.hpp:29
void clamp_max(Array &array, float vmax)
Clamp array values larger than a given bound.
Definition range.cpp:87
void clamp(Array &array, float vmin=0.f, float vmax=1.f)
Clamp array elements to a target range.
Definition range.cpp:48
Array minimum(const Array &array1, const Array &array2)
Return the element-wise minimum of two arrays.
Definition range.cpp:355
void clamp_oblique_plane(Array &array, float vmax, float angle, float slope, bool use_max_operator=true, float k=0.f, glm::vec2 center={0.5f, 0.5f}, const BBox2D &bbox=BBox2D::unit())
Clamps an array against an oblique plane.
Definition range.cpp:230
Axis-aligned 2D bounding box in world coordinates.
Definition bbox2d.hpp:25
static constexpr BBox2D unit()
Definition bbox2d.hpp:39