HighMap library (C++)
Loading...
Searching...
No Matches
coord_frame.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#include <cmath>
14#include <map>
15#include <vector>
16
17#include "highmap/algebra.hpp"
18#include "highmap/heightmap.hpp"
19
20namespace hmap
21{
22
24{
25public:
26 CoordFrame();
27
28 CoordFrame(Vec2<float> origin, Vec2<float> size, float rotation_angle);
29
30 // Getters
32 {
33 return this->origin;
34 }
35
37 {
38 return this->size;
39 }
40
41 float get_rotation_angle() const;
42
43 // Setters
44 void set_origin(Vec2<float> new_origin)
45 {
46 this->origin = new_origin;
47 }
48
49 void set_size(Vec2<float> new_size)
50 {
51 this->size = new_size;
52 }
53
54 void set_rotation_angle(float new_angle);
55
56 // Methods
57
59
61 float gx,
62 float gy,
63 float fill_value = 0.f) const;
64
66 float gx,
67 float gy,
68 float fill_value = 0.f) const;
69
70 bool is_point_within(float gx, float gy) const;
71
72 Vec2<float> map_to_global_coords(float rx, float ry) const;
73
74 // relative coords always in [0, 1] x [0, 1] (unit square)
75 Vec2<float> map_to_relative_coords(float gx, float gy) const;
76
77 float normalized_distance_to_edges(float gx, float gy) const;
78
79 float normalized_shape_factor(float gx, float gy) const;
80
81private:
82 Vec2<float> origin;
83 Vec2<float> size;
84 float rotation_angle;
85
86 float cos_angle;
87 float sin_angle;
88};
89
90} // namespace hmap
Header file defining basic vector and matrix manipulation classes.
Definition coord_frame.hpp:24
void set_origin(Vec2< float > new_origin)
Definition coord_frame.hpp:44
float get_heightmap_value_nearest(const Heightmap &h, float gx, float gy, float fill_value=0.f) const
Definition coord_frame.cpp:68
float get_heightmap_value_bilinear(const Heightmap &h, float gx, float gy, float fill_value=0.f) const
Definition coord_frame.cpp:53
void set_rotation_angle(float new_angle)
Definition coord_frame.cpp:98
Vec2< float > get_origin() const
Definition coord_frame.hpp:31
void set_size(Vec2< float > new_size)
Definition coord_frame.hpp:49
Vec2< float > map_to_global_coords(float rx, float ry) const
Definition coord_frame.cpp:108
bool is_point_within(float gx, float gy) const
Definition coord_frame.cpp:89
Vec2< float > map_to_relative_coords(float gx, float gy) const
Definition coord_frame.cpp:120
CoordFrame()
Definition coord_frame.cpp:11
float normalized_shape_factor(float gx, float gy) const
Definition coord_frame.cpp:149
Vec2< float > get_size() const
Definition coord_frame.hpp:36
float get_rotation_angle() const
Definition coord_frame.cpp:83
Vec4< float > compute_bounding_box() const
Definition coord_frame.cpp:25
float normalized_distance_to_edges(float gx, float gy) const
Definition coord_frame.cpp:137
HeightMap class, to manipulate heightmap (with contextual informations).
Definition heightmap.hpp:150
Definition algebra.hpp:28
Vec2 class for basic manipulation of 2D vectors.
Definition algebra.hpp:40
Vec4 class for basic manipulation of 4D vectors.
Definition algebra.hpp:564