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