Skip to content

Commit

Permalink
Fix a bug in KalmanPredictor from FuzzTest.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 654840024
  • Loading branch information
Ink Open Source authored and copybara-github committed Jul 22, 2024
1 parent eeba707 commit 6754cff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ink_stroke_modeler/internal/prediction/kalman_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <algorithm>
#include <cmath>
#include <cstddef>
#include <limits>
#include <optional>
#include <vector>

Expand Down Expand Up @@ -151,7 +152,8 @@ void KalmanPredictor::ConstructCubicConnector(
// to the estimated position, based on the start and end velocities. We define
// a minimum "reasonable" velocity to avoid division by zero.
float distance_traveled =
Distance(last_tip_state.position, estimated_state.position);
std::min(Distance(last_tip_state.position, estimated_state.position),
std::numeric_limits<float>::max());
float max_velocity_at_ends = std::max(last_tip_state.velocity.Magnitude(),
estimated_state.velocity.Magnitude());
Duration target_duration{
Expand Down

0 comments on commit 6754cff

Please sign in to comment.