34 Grid2D(
size_t width,
size_t height);
43 Grid2D(
size_t width,
size_t height,
const std::vector<float> data);
68 void save(std::ostream &os)
const;
110 void setValue(
size_t x,
size_t y,
float value);
126 float getValue(
size_t x,
size_t y)
const;
134 float sample(
float x,
float y)
const ;
212 void fill(
float value);
229 std::vector<float> data{};
237 size_t index(
size_t x,
size_t y)
const;
244 std::pair<size_t,size_t> findMaxSize(
const Grid2D& other)
const;
RAII wrapper for an OpenGL 2D texture with byte/half/float upload helpers.
Lightweight image container with basic processing utilities.
2D vector template with arithmetic, length utilities, and helpers.
Vec2t< float > Vec2
Float vector (x,y).
Definition Vec2.h:258
3D vector template with arithmetic, geometry helpers, and RNG utilities.
Vec3t< float > Vec3
3D float vector (x,y,z).
Definition Vec3.h:424
Definition GLTexture2D.h:19
Grid2D operator/(const float &value) const
Per‑element divide by scalar.
Definition Grid2D.cpp:183
Grid2D operator-(const float &value) const
Per‑element subtract scalar.
Definition Grid2D.cpp:175
void normalize(const float maxVal=1)
Normalize values to [0,maxVal] by affine remapping.
Definition Grid2D.cpp:384
std::string toString() const
String dump of values in row‑major order.
Definition Grid2D.cpp:52
static Grid2D fromBMP(const std::string &filename)
Create a grid from the luminance of a BMP file.
Definition Grid2D.cpp:432
void fill(float value)
Fill all elements with a constant.
Definition Grid2D.cpp:448
friend std::ostream & operator<<(std::ostream &os, const Grid2D &v)
Stream insertion (delegates to toString()).
Definition Grid2D.cpp:428
Grid2D operator+(const float &value) const
Per‑element add scalar.
Definition Grid2D.cpp:167
Grid2D toSignedDistance(float threshold) const
Compute a signed distance field from a binary threshold.
Definition Grid2D.cpp:479
Vec2t< size_t > maxValue() const
Location of the maximum value.
Definition Grid2D.cpp:400
Vec3 normal(float x, float y) const
Estimate a normal from local height differences at normalized coords.
Definition Grid2D.cpp:119
float getValue(size_t x, size_t y) const
Fetch value by integer coordinates.
Definition Grid2D.cpp:83
Vec2t< size_t > minValue() const
Location of the minimum value.
Definition Grid2D.cpp:412
GLTexture2D toTexture() const
Upload to an OpenGL texture (1 channel).
Definition Grid2D.cpp:558
Grid2D operator*(const float &value) const
Per‑element multiply by scalar.
Definition Grid2D.cpp:159
Grid2D(size_t width, size_t height)
Construct an empty grid initialized to zeros.
Definition Grid2D.cpp:11
size_t getWidth() const
Grid width in elements.
Definition Grid2D.cpp:44
static Grid2D genRandom(size_t x, size_t y, uint32_t seed)
Generate a grid of random values in [0,1) using a fixed seed.
Definition Grid2D.cpp:142
std::vector< uint8_t > toByteArray() const
Convert to an 8‑bit RGB byte array (grayscale replicated to RGB).
Definition Grid2D.cpp:64
void setValue(size_t x, size_t y, float value)
Set one value.
Definition Grid2D.cpp:74
float getValueNormalized(float x, float y) const
Fetch value using normalized [0,1] coordinates (nearest‑neighbor via index mapping).
Definition Grid2D.cpp:79
float sample(float x, float y) const
Bilinear sample at normalized coordinates in [0,1].
Definition Grid2D.cpp:92
size_t getHeight() const
Grid height in elements.
Definition Grid2D.cpp:48
void save(std::ostream &os) const
Write grid to a binary stream.
Definition Grid2D.cpp:461