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"
19
20namespace hmap
21{
22
24{
25public:
26 CoordFrame();
27
28 CoordFrame(glm::vec2 origin, glm::vec2 size, float rotation_angle);
29
30 // Getters
31 glm::vec2 get_origin() const
32 {
33 return this->origin;
34 }
35
36 glm::vec2 get_size() const
37 {
38 return this->size;
39 }
40
41 float get_rotation_angle() const;
42
43 // Setters
44 void set_origin(glm::vec2 new_origin)
45 {
46 this->origin = new_origin;
47 }
48
49 void set_size(glm::vec2 new_size)
50 {
51 this->size = new_size;
52 }
53
54 void set_rotation_angle(float new_angle);
55
56 // Methods
57
58 glm::vec4 compute_bounding_box() const;
59
61 float gx,
62 float gy,
63 float fill_value = 0.f) const;
64
65 bool is_point_within(float gx, float gy) const;
66
67 glm::vec2 map_to_global_coords(float rx, float ry) const;
68
69 // relative coords always in [0, 1] x [0, 1] (unit square)
70 glm::vec2 map_to_relative_coords(float gx, float gy) const;
71
72 float normalized_distance_to_edges(float gx, float gy) const;
73
74 float normalized_shape_factor(float gx, float gy) const;
75
76private:
77 glm::vec2 origin;
78 glm::vec2 size;
79 float rotation_angle;
80
81 float cos_angle;
82 float sin_angle;
83};
84
85} // namespace hmap
Header file defining basic vector and matrix manipulation classes.
Definition coord_frame.hpp:24
void set_origin(glm::vec2 new_origin)
Definition coord_frame.hpp:44
void set_rotation_angle(float new_angle)
Definition coord_frame.cpp:81
glm::vec2 map_to_global_coords(float rx, float ry) const
Definition coord_frame.cpp:91
float get_heightmap_value_bilinear(const VirtualArray &h, float gx, float gy, float fill_value=0.f) const
Definition coord_frame.cpp:51
void set_size(glm::vec2 new_size)
Definition coord_frame.hpp:49
bool is_point_within(float gx, float gy) const
Definition coord_frame.cpp:72
glm::vec2 get_size() const
Definition coord_frame.hpp:36
glm::vec4 compute_bounding_box() const
Definition coord_frame.cpp:23
glm::vec2 get_origin() const
Definition coord_frame.hpp:31
CoordFrame()
Definition coord_frame.cpp:11
float normalized_shape_factor(float gx, float gy) const
Definition coord_frame.cpp:132
glm::vec2 map_to_relative_coords(float gx, float gy) const
Definition coord_frame.cpp:103
float get_rotation_angle() const
Definition coord_frame.cpp:66
float normalized_distance_to_edges(float gx, float gy) const
Definition coord_frame.cpp:120
Definition algebra.hpp:22
Definition virtual_array.hpp:62