Horizon
geom_util.hpp
1 #pragma once
2 #include <string>
3 #include "common/common.hpp"
4 #include "util/placement.hpp"
5 
6 namespace horizon {
7 
8 template <typename T> std::pair<Coord<T>, Coord<T>> pad_bbox(std::pair<Coord<T>, Coord<T>> bb, T pad)
9 {
10  bb.first.x -= pad;
11  bb.first.y -= pad;
12 
13  bb.second.x += pad;
14  bb.second.y += pad;
15  return bb;
16 }
17 Coordd project_onto_perp_bisector(const Coordd &a, const Coordd &b, const Coordd &p);
18 
19 std::string coord_to_string(const Coordf &c, bool delta = false);
20 std::string dim_to_string(int64_t x, bool with_sign = true);
21 std::string angle_to_string(int angle, bool pos_only = true);
22 int orientation_to_angle(Orientation o);
23 int64_t round_multiple(int64_t x, int64_t mul);
24 
25 template <typename T> int sgn(T val)
26 {
27  return (T(0) < val) - (val < T(0));
28 }
29 
30 double angle_to_rad(int angle);
31 int angle_from_rad(double rad);
32 int wrap_angle(int angle);
33 template <typename T> T c2pi(T x);
34 
35 Placement transform_package_placement_to_new_reference(Placement pl, Placement old_ref, Placement new_ref);
36 Placement transform_text_placement_to_new_reference(Placement pl, Placement old_ref, Placement new_ref);
37 
38 } // namespace horizon
list< F, S > pair
A list with exactly two elements.
Definition: meta.hpp:2246