Skip to content

Commit

Permalink
fix: 🐛 Fix Fisheye transformation implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
ion098 committed Jan 29, 2025
1 parent 371182d commit 8828d33
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gamepad/joystick_transformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ std::pair<float, float> Fisheye::get_value(std::pair<float, float> value) {
float y_abs = abs(y);
float j = std::sqrt(m_radius * m_radius - 1.0 * 1.0);
if (x_abs >= j && y_abs >= j) {
float theta = std::atan2(y_abs, x_abs);
x_abs *= m_radius / std::cos(abs(std::remainder(theta, 90)));
y_abs *= m_radius / std::cos(abs(std::remainder(theta, 90)));
float scale = std::hypot(std::min(x_abs / y_abs, y_abs / x_abs), 1.0) / m_radius;
x_abs *= scale;
y_abs *= scale;
}
x = std::copysign(std::min(1.0f, x_abs), x);
y = std::copysign(std::min(1.0f, y_abs), y);
Expand Down

0 comments on commit 8828d33

Please sign in to comment.