Add arc-length easing to mouse trajectory for natural velocity profile#231
Open
ulziibay-kernel wants to merge 1 commit intomainfrom
Open
Add arc-length easing to mouse trajectory for natural velocity profile#231ulziibay-kernel wants to merge 1 commit intomainfrom
ulziibay-kernel wants to merge 1 commit intomainfrom
Conversation
The previous tweenPoints used easeOutQuad on array indices, producing near-constant pixel distances between consecutive points (~15px per step). With Gaussian timing jitter (PR #228), velocity = distance/time still has low variance because the distance component is constant. Real human mouse movement follows a bell-shaped velocity profile: slow acceleration from rest, peak speed in the middle, deceleration to the target (Fitts's law / minimum-jerk model). This requires varying the pixel distance per step, not just the timing. Replace index-based easeOutQuad with arc-length-based easeInOutCubic: - Build cumulative arc-length table along the Bezier curve - Sample at non-uniform arc-length positions via easeInOutCubic - Binary search + linear interpolation for sub-segment precision Result: steps range from ~3px at endpoints to ~25px in the middle, creating the distance variance that produces human-like velocity variance when combined with Gaussian timing. Made-with: Cursor
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: This PR modifies mouse trajectory easing logic (likely in a client or utility package), not kernel API endpoints or Temporal workflows as specified in the filter. To monitor this PR anyway, reply with |
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
Replaces index-based
easeOutQuadpoint sampling intweenPointswith arc-length-basedeaseInOutCubicsampling, so the Bezier trajectory produces physically varying pixel distances per step — small at start/end, large in the middle.Problem
PR #228 added Gaussian timing jitter to mouse movement delays, but velocity = distance / time. The distance component was still near-constant (~15px per step) because the old
easeOutQuadsampled by array index, which doesn't translate to physical spacing:Velocity variance stays low (~0.08-3.21) despite varying timing, because pixel distance is constant.
Real human movement has a bell-shaped velocity profile (Fitts's law):
Fix
tweenPointsnow:t ∈ [0,1]througheaseInOutCubicto get non-uniform arc-length positionsThis produces:
Combined with Gaussian timing from #228, velocity = (varying distance) / (varying time) → high variance matching human motor noise.
Test plan
TestHumanizeMouseTrajectory_VelocityProfile— verifies middle steps are larger than initial steps (acceleration profile) and step distance variance is substantial (>5)Made with Cursor
Note
Medium Risk
Moderate risk because it changes the core point-sampling algorithm and could alter downstream mouse movement behavior/anti-bot characteristics, though it’s localized and covered by a new regression test.
Overview
Updates
HumanizeMouseTrajectory.tweenPointsto replace index-basedeaseOutQuadsampling with arc-length-based sampling driven byeaseInOutCubic, including binary search + interpolation and guards for short/zero-length paths, so consecutive step distances vary (slow at start/end, faster mid-curve).Adds
TestHumanizeMouseTrajectory_VelocityProfileto assert the new bell-shaped step-distance profile (middle steps larger than early steps, with non-trivial variance).Reviewed by Cursor Bugbot for commit f2c8aa5. Bugbot is set up for automated code reviews on this repo. Configure here.