Horizon
Loading...
Searching...
No Matches
geom_util.hpp
1#pragma once
2#include <string>
3#include "common/common.hpp"
4#include "util/placement.hpp"
5
6namespace horizon {
7
8template <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}
17Coordd project_onto_perp_bisector(const Coordd &a, const Coordd &b, const Coordd &p);
18
19std::string coord_to_string(const Coordf &c, bool delta = false);
20std::string dim_to_string(int64_t x, bool with_sign = true);
21std::string angle_to_string(int angle, bool pos_only = true);
22int orientation_to_angle(Orientation o);
23int64_t round_multiple(int64_t x, int64_t mul);
24
25template <typename T> int sgn(T val)
26{
27 return (T(0) < val) - (val < T(0));
28}
29
30double angle_to_rad(int angle);
31int angle_from_rad(double rad);
32int wrap_angle(int angle);
33template <typename T> T c2pi(T x);
34
35Placement transform_package_placement_to_new_reference(Placement pl, Placement old_ref, Placement new_ref);
36Placement transform_text_placement_to_new_reference(Placement pl, Placement old_ref, Placement new_ref);
37
38} // namespace horizon