fix possible wraparound

This commit is contained in:
2026-08-11 12:06:03 +02:00
parent abf1226b47
commit 831501ea41
+3 -2
View File
@@ -17,6 +17,7 @@
#include <iostream> #include <iostream>
#include <numbers> #include <numbers>
#include <string> #include <string>
#include <algorithm>
#ifndef CONFIG_AUTOSCALE #ifndef CONFIG_AUTOSCALE
constexpr constexpr
@@ -184,8 +185,8 @@ int main() {
const float vector_lenght = const float vector_lenght =
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT; (speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
draw::line(x_center, y_center, draw::line(x_center, y_center,
x_center + (vector_lenght * std::cos(track_rad)), std::clamp(x_center + (vector_lenght * std::cos(track_rad)),0.0f, static_cast<float>(UINT16_MAX)),
y_center + (vector_lenght * std::sin(track_rad)), color); std::clamp(y_center + (vector_lenght * std::sin(track_rad)),0.0f,static_cast<float>(UINT16_MAX)), color);
#endif #endif
draw::rhombus(x_center, y_center, 8 /*TODO: remove magic*/, draw::rhombus(x_center, y_center, 8 /*TODO: remove magic*/,
color); color);