20#include "NoiseLib/include/controlfunction.h"
21#include "NoiseLib/include/math2d.h"
22#include "NoiseLib/include/utils.h"
42 x = std::clamp(x, 0.f, 1.f);
43 y = std::clamp(y, 0.f, 1.f);
50 return x >= 0.f && x <= 1.f && y >= 0.f && y <= 1.f;
60 const Point2D p(x, y);
62 const Point2D topLeft(0.f, 0.f);
63 const Point2D topRight(1.f, 0.f);
64 const Point2D bottomLeft(0.f, 1.f);
65 const Point2D bottomRight(1.f, 1.f);
69 auto dist = std::numeric_limits<float>::max();
71 dist = std::min(dist, distToLineSegment(p, topLeft, topRight, c));
72 dist = std::min(dist, distToLineSegment(p, topRight, bottomRight, c));
73 dist = std::min(dist, distToLineSegment(p, bottomRight, bottomLeft, c));
74 dist = std::min(dist, distToLineSegment(p, bottomLeft, topLeft, c));
90 float get(
int i,
int j)
const
92 return (
float)m_array(i, j);
95 float sample(
float ri,
float rj)
const
97 float x = ri * (m_array.
shape.
x - 1);
98 float y = rj * (m_array.
shape.
y - 1);
106 if (i == m_array.
shape.
x - 1)
114 if (j == m_array.
shape.
y - 1)
136 : noise_function(noise_function), offset(offset), scaling(scaling)
143 return offset + scaling * noise_function.
get_delegate()(x, y, 0.f);
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Definition dendry_array_control_function.hpp:31
float DistToDomainImpl(float x, float y) const
Definition dendry_array_control_function.hpp:53
float MaximumImpl() const
Definition dendry_array_control_function.hpp:84
float EvaluateImpl(float x, float y) const
Definition dendry_array_control_function.hpp:40
float MinimumImpl() const
Definition dendry_array_control_function.hpp:79
bool InsideDomainImpl(float x, float y) const
Definition dendry_array_control_function.hpp:48
ArrayControlFunction(hmap::Array array)
Definition dendry_array_control_function.hpp:35
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
float get_value_bilinear_at(int i, int j, float u, float v) const
Retrieves the array value at the location (x, y) near the index (i, j) using bilinear interpolation.
Definition methods.cpp:208
Vec2< int > shape
The shape of the array {ni, nj}.
Definition array.hpp:38
HMAP_FCT_XY_TYPE get_delegate() const
Get the current delegate function.
Definition functions.cpp:38
A class for generating noise functions.
Definition functions.hpp:693
Definition dendry_array_control_function.hpp:129
double EvaluateImpl(float x, float y) const
Definition dendry_array_control_function.hpp:141
XyControlFunction(NoiseFunction noise_function, float offset=0.f, float scaling=1.f)
Definition dendry_array_control_function.hpp:133
double DistToDomainImpl(float x, float y) const
Definition dendry_array_control_function.hpp:151
bool InsideDomainImpl(float x, float y) const
Definition dendry_array_control_function.hpp:146
double MaximumImpl() const
Definition dendry_array_control_function.hpp:161
double MinimumImpl() const
Definition dendry_array_control_function.hpp:156
Defines modular function objects for procedural generation, including noise algorithms (Perlin,...
Definition algebra.hpp:28
T y
The x and y components of the vector.
Definition algebra.hpp:41
T x
Definition algebra.hpp:41