Fix Precision Bugs in ConvexHull and SaccadeVelocity#70
Merged
oscararenas12 merged 1 commit intomainfrom Dec 6, 2025
Merged
Conversation
- Remove (long) casts in ConvexHull that truncated floating-point values - Return NaN instead of 0.0 when all velocities exceed threshold - Fix writeCSV.csv line endings (CRLF to LF) for OpenCSV 5.x compatibility
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
1. ConvexHull.java - Floating-Point Truncation Fix
Problem: The
(long)casts truncated decimal portions of coordinates before performing calculations, causing precision loss in angle and distance computations.Affected locations:
thetaA,thetaB)distanceA,distanceB)getTurn()Example of precision loss:
Before:
After:
Why the original comment was wrong: The code uses
Point2D.Doublewhich hasdoublefields. There's no integer overflow/underflow risk - the(long)casts were unnecessary and harmful.2. SaccadeVelocity.java - Zero Velocity Bug Fix
Problem: When all velocities in a saccade exceeded the 700°/s threshold,
getPeakVelocity()returned0.0instead ofNaN. This0.0was included in aggregate statistics, artificially lowering min/mean/median values.Before:
After:
Impact on statistics:
0.0(included in stats)NaN(excluded)NaNNaNExample:
3. SaccadeVelocityTest.java - Updated Test
Updated test to expect
NaNinstead of0when all velocities exceed threshold:Before:
After:
4. writeCSV.csv - Line Ending Fix
Problem: OpenCSV 5.x defaults to LF (
\n) line endings, but the expected test file used CRLF (\r\n), causingFileUtils.contentEquals()to fail.Fix: Converted
src/test/resources/writeCSV.csvfrom CRLF to LF:sed -i 's/\r$//' src/test/resources/writeCSV.csvTest Verification
All 95 tests pass:
Specific test results:
ConvexHullTest: 6/6 passedSaccadeVelocityTest: 6/6 passedDataEntryTest: 5/5 passedFiles Changed
src/main/java/.../ConvexHull.java(long)casts (3 locations)src/main/java/.../SaccadeVelocity.javafoundValidVelocityflag, returnNaNwhen no valid velocitiessrc/test/java/.../SaccadeVelocityTest.javaNaNsrc/test/resources/writeCSV.csvRelated Issues
These fixes align BEACH-Gaze behavior with TIDE-Gaze (Python implementation) for consistent cross-platform gaze analytics results.