-
-
Notifications
You must be signed in to change notification settings - Fork 9
fix: current speed stuck at 0 B/s (unstable spring animation) #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 0.2.1 | ||
| 0.2.2 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,3 +48,22 @@ func TestSpringConverges(t *testing.T) { | |||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Errorf("Spring did not converge: %f (want ~100)", val) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| func TestSpringStableAtUITickInterval(t *testing.T) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const target = 34603008.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| var vel float64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val := 0.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| minVal := val | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| for i := 0; i < 1000; i++ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| val = Spring(val, target, &vel, 0.13) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if val < minVal { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| minVal = val | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if math.Abs(val-target) > target*0.01 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Errorf("Spring did not converge at dt=0.13: %f (want ~%f)", val, target) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if minVal < 0 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| t.Errorf("Spring oscillated negative at dt=0.13 (min %f) — value would render as 0 B/s", minVal) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+57
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Reject non-finite values explicitly. If Proposed test fix for i := 0; i < 1000; i++ {
val = Spring(val, target, &vel, 0.13)
+ if math.IsNaN(val) || math.IsInf(val, 0) {
+ t.Fatalf("Spring returned a non-finite value at tick %d: %f", i, val)
+ }
if val < minVal {
minVal = val
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Limit and correct the stability claim.
Exponential damping keeps the damping multiplier positive, but
Springstill performs explicit force integration without adtbound or substepping. This change does not establish convergence at every possible step size. Limit the claim to the tested 130 ms UI interval unless a timestep contract is added. Also changeevaluatedtoevaluates.Proposed changelog fix
📝 Committable suggestion
🧰 Tools
🪛 LanguageTool
[grammar] ~4-~4: Ensure spelling is correct
Context: ...cally unstable at the UI tick interval (130ms), since
1 - damping*dtevaluated to a...(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents
Source: Linters/SAST tools