10 #include "../math.hpp"
17 template <
typename T,
typename U>
27 template <
typename T,
typename U>
28 auto circle(
float x,
float y,
float radius,
unsigned int resolution = 72)
30 throw std::runtime_error(
"");
39 unsigned int resolution
40 ) -> Geometry<SDL_Vertex, int>;
49 unsigned int resolution = 100,
51 ) -> Geometry<SDL_Vertex, int>;
76 unsigned int resolution = 100
78 static constexpr
auto tau = (std::numbers::pi_v<float> * 2.f);
79 const float resf =
static_cast<float>(resolution);
80 const unsigned int arcRes = round((width / tau) * resf);
81 std::vector<T> vertices(arcRes * 2 + 3);
82 for (
unsigned int i = 0; i <= arcRes; i++) {
85 const float px = cos(a) * (radius - height) + x;
86 const float py = sin(a) * (radius - height) + y;
87 vertices[i] = T {px, py};
91 const float px = cos(a) * radius + x;
92 const float py = sin(a) * radius + y;
93 vertices[arcRes + i + 1] = T {px, py};
96 vertices[vertices.size() - 1] = vertices[0];