From 306e7488e00f128812cd28fbf93a90329b2d7006 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Sat, 3 Jan 2026 13:20:04 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Replace=20arduino=20math?= =?UTF-8?q?=20function=20with=20cmath?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp32/include/kinematics.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp32/include/kinematics.h b/esp32/include/kinematics.h index 9ea31dc..3e54ae5 100644 --- a/esp32/include/kinematics.h +++ b/esp32/include/kinematics.h @@ -184,13 +184,13 @@ class Kinematics { } inline void legIK(float x, float y, float z, float out[3]) { - float F = sqrt(max(0.0f, x * x + y * y - coxa * coxa)); + float F = sqrt(fmax(0.0f, x * x + y * y - coxa * coxa)); float G = F - coxa_offset; float H = sqrt(G * G + z * z); float theta1 = -atan2f(y, x) - atan2f(F, -coxa); float D = (H * H - femur * femur - tibia * tibia) / (2 * femur * tibia); - float theta3 = acosf(max(-1.0f, min(1.0f, D))); + float theta3 = acosf(fmax(-1.0f, fmin(1.0f, D))); float theta2 = atan2f(z, G) - atan2f(tibia * sinf(theta3), femur + tibia * cosf(theta3)); out[0] = RAD_TO_DEG_F(theta1); out[1] = RAD_TO_DEG_F(theta2);