diff --git a/include/omath/algorithm/radar.hpp b/include/omath/algorithm/radar.hpp index 3ca40df..bfbf722 100644 --- a/include/omath/algorithm/radar.hpp +++ b/include/omath/algorithm/radar.hpp @@ -15,12 +15,13 @@ namespace omath::algorithm auto look_at_angles = camera.calc_look_at_angles(position); auto current_angles = camera.get_view_angles(); - auto yaw = look_at_angles.yaw - current_angles.yaw + decltype(current_angles.yaw)::from_degrees(180); - auto right_yaw = camera.calc_look_at_angles(camera.get_origin() + camera.get_abs_right()).yaw - - current_angles.yaw + decltype(current_angles.yaw)::from_degrees(180); - const auto right_scale = right_yaw.sin() < 0 ? -1.f : 1.f; + auto yaw = current_angles.yaw - look_at_angles.yaw - decltype(current_angles.yaw)::from_degrees(90); + auto right_yaw = current_angles.yaw + - camera.calc_look_at_angles(camera.get_origin() + camera.get_abs_right()).yaw + - decltype(current_angles.yaw)::from_degrees(90); + const auto sign = right_yaw.cos() < 0 ? -1.f : 1.f; - return omath::Vector2(static_cast(yaw.sin()) * right_scale, yaw.cos()) + return omath::Vector2(static_cast(yaw.cos()) * sign, static_cast(yaw.sin())) * (camera.get_origin().distance_to(position) * scale); } } // namespace omath::algorithm