Omni-wheel robot wheel speed calculation library

Revision:
1:74cfff9b981e
Parent:
0:14717ae9875d
Child:
2:e4b06a9b3ff2
--- a/omni.h	Sun Jun 19 04:36:13 2022 +0900
+++ b/omni.h	Mon Jun 20 00:40:33 2022 +0900
@@ -1,6 +1,6 @@
 #include <array>
-#include <iterator>
 #include <cmath>
+#include <algorithm>
 
 template <size_t wheelSize>
 class Omni {
@@ -19,7 +19,7 @@
       for(int i = 0; i < wheelSize; i++) {
         m_outs[i] = sin(rad + radians[i]) * r + a;
       }
-      const float maxOut = std::max(std::abs(*std::max(m_outs.begin(), m_outs.end())), std::abs(*std::min(m_outs.begin(), m_outs.end())));
+      const float maxOut = *std::max_element(m_outs.begin(), m_outs.end(), [](const auto& a, const auto& b){return std::abs(a) < std::abs(b);});
       if(maxOut > 1.0) {
         for(auto& out: m_outs) {
           out *= (1.0 / maxOut);