header_utils
Loading...
Searching...
No Matches
rectangles.h
1
4
5#pragma once
6
7#include "geometry_common.h"
8#include "../rec2.h"
9
10namespace ghassanpl::geometry
11{
12 static_assert(shape<rec2, float>);
13
14 template <typename T>
15 tpolygon<T> polygon_from(const trec2<T>& r /*, winding_t winding = clockwise */)
16 {
17 return tpolygon<T>{
18 r.left_top(),
19 r.right_top(),
20 r.right_bottom(),
21 r.left_bottom()
22 };
23 }
24
25 template <typename T>
26 std::array<tsegment<T>, 4> edges_of(const trec2<T>& r /*, winding_t winding = clockwise */)
27 {
28 return std::array<tsegment<T>, 4>{
29 tsegment<T>{r.left_top(), r.right_top()},
30 tsegment<T>{r.right_top(), r.right_bottom()},
31 tsegment<T>{r.right_bottom(), r.left_bottom()},
32 tsegment<T>{r.left_bottom(), r.left_top()}
33 };
34 }
35
36 /*
37 template <typename T>
38 tcircle<T> inner_circle(const trec2<T>& r);
39 template <typename T>
40 tcircle<T> outer_circle(const trec2<T>& r);
41 */
42}
constexpr auto bit_count
Equal to the number of bits in the type.
Definition bits.h:33