HighMap library (C++)
Loading...
Searching...
No Matches
transform.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
12#pragma once
13
14#include <cstdint>
15
16#include "highmap/array.hpp"
17
18namespace hmap
19{
20
25// clang-format off
37// clang-format on
38
53void flip_lr(Array &array);
54
69void flip_ud(Array &array);
70
87void radial_displacement_to_xy(const Array &dr,
88 Array &dx,
89 Array &dy,
90 float smoothing = 1.f,
91 glm::vec2 center = {0.5f, 0.5f},
92 const UvRect &uv_rect = UvRect::unit());
93
102void rot180(Array &array);
103
112void rot270(Array &array);
113
128void rot90(Array &array);
129
150void rotate(Array &array,
151 float angle,
152 bool zoom_in = true,
153 bool zero_padding = false);
154
169void rotate_displacement(const Array &delta, float angle, Array &dx, Array &dy);
170
177void scale_uv(Array &array, glm::vec2 uv_scale);
178
194 const Array &array,
196 bool flatten_center = false,
197 float flatten_radius = 0.05f);
198
234Array translate(const Array &array,
235 float dx,
236 float dy,
237 bool periodic = false,
238 const Array *p_noise_x = nullptr,
239 const Array *p_noise_y = nullptr,
240 const UvRect &uv_rect = UvRect::unit());
241
252Array transpose(const Array &array);
253
300Array zoom(const Array &array,
301 float zoom_factor,
302 bool periodic = false,
303 glm::vec2 center = {0.5f, 0.5f},
304 const Array *p_noise_x = nullptr,
305 const Array *p_noise_y = nullptr,
306 const UvRect &uv_rect = UvRect::unit());
307
308} // namespace hmap
309
310namespace hmap::gpu
311{
312
314void rotate(Array &array, float angle, bool zoom_in = true);
315
316} // namespace hmap::gpu
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:31
Definition array_blending.hpp:225
void rotate(Array &array, float angle, bool zoom_in=true)
See hmap::rotate.
Definition transform_gpu.cpp:16
Definition opencv.hpp:20
void rot270(Texture &texture)
Rotate the texture by 270 degrees counterclockwise.
Definition texture_transform.cpp:56
Array symmetrize(const Array &array, SymmetryType symmetry_type=SymmetryType::SYMMETRY_LEFT_TO_RIGHT, bool flatten_center=false, float flatten_radius=0.05f)
Enforces geometric symmetry on an array.
Definition transform.cpp:190
void flip_ud(Texture &texture)
Flip the texture vertically (up/down).
Definition texture_transform.cpp:25
void rot90(Texture &texture)
Rotate the texture by 90 degrees counterclockwise.
Definition texture_transform.cpp:35
SymmetryType
Describes the symmetry operation to apply to an array.
Definition transform.hpp:27
@ SYMMETRY_TOP_TO_BOTTOM
Mirror top half onto bottom half.
Definition transform.hpp:30
@ SYMMETRY_LEFT_TO_RIGHT
Mirror left half onto right half.
Definition transform.hpp:28
@ SYMMETRY_RIGHT_TO_LEFT
Mirror right half onto left half.
Definition transform.hpp:29
@ SYMMETRY_Y
Symmetric average across horizontal axis.
Definition transform.hpp:33
@ SYMMETRY_ROT180
180-degree rotational symmetry around center.
Definition transform.hpp:35
@ SYMMETRY_X
Symmetric average across vertical axis.
Definition transform.hpp:32
@ SYMMETRY_BOTTOM_TO_TOP
Mirror bottom half onto top half.
Definition transform.hpp:31
@ SYMMETRY_XY
4-quadrant symmetric average across both X and Y.
Definition transform.hpp:34
void rotate(Array &array, float angle, bool zoom_in=true, bool zero_padding=false)
Rotate the array by a specified angle.
Definition transform.cpp:94
void rot180(Texture &texture)
Rotate the texture by 180 degrees.
Definition texture_transform.cpp:46
Array translate(const Array &array, float dx, float dy, bool periodic=false, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Translates a 2D array by a specified amount along the x and y axes.
Definition transform.cpp:299
void scale_uv(Texture &texture, glm::vec2 uv_scale)
Scale the texture in UV space with wrapping boundary.
Definition texture_transform.cpp:67
Texture transpose(const Texture &texture)
Return the transposed texture.
Definition texture_transform.cpp:77
float angle(const Point &p1, const Point &p2)
Computes the angle between two points relative to the x-axis.
Definition points.cpp:65
void rotate_displacement(const Array &delta, float angle, Array &dx, Array &dy)
Rotates a scalar displacement field into directional X and Y components.
Definition transform.cpp:138
Array zoom(const Array &array, float zoom_factor, bool periodic=false, glm::vec2 center={0.5f, 0.5f}, const Array *p_noise_x=nullptr, const Array *p_noise_y=nullptr, const UvRect &uv_rect=UvRect::unit())
Applies a zoom effect to a 2D array with an adjustable center.
Definition transform.cpp:350
void flip_lr(Texture &texture)
Flip the texture horizontally (left/right).
Definition texture_transform.cpp:15
void radial_displacement_to_xy(const Array &dr, Array &dx, Array &dy, float smoothing=1.f, glm::vec2 center={0.5f, 0.5f}, const UvRect &uv_rect=UvRect::unit())
Interpret the input array dr as a radial displacement and convert it to a pair of displacements dx an...
Definition transform.cpp:41
Axis-aligned rectangle in normalized [0, 1]^2 domain/UV space.
Definition uv_rect.hpp:30
static constexpr UvRect unit()
Definition uv_rect.hpp:46