fix possible wraparound
This commit is contained in:
+3
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user