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 <numbers>
#include <string>
#include <algorithm>
#ifndef CONFIG_AUTOSCALE
constexpr
@@ -184,8 +185,8 @@ int main() {
const float vector_lenght =
(speed_pph / 60) * CONFIG_TIME_BASED_VECTOR_LENGHT;
draw::line(x_center, y_center,
x_center + (vector_lenght * std::cos(track_rad)),
y_center + (vector_lenght * std::sin(track_rad)), color);
std::clamp(x_center + (vector_lenght * std::cos(track_rad)),0.0f, static_cast<float>(UINT16_MAX)),
std::clamp(y_center + (vector_lenght * std::sin(track_rad)),0.0f,static_cast<float>(UINT16_MAX)), color);
#endif
draw::rhombus(x_center, y_center, 8 /*TODO: remove magic*/,
color);