#6182 Improve calculate_circle_center#6192
Conversation
|
QA Wolf here! As you write new code it's important that your test coverage is keeping up. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
CodSpeed Walltime Performance ReportMerging #6192 will degrade performances by 14.92%Comparing
|
| Benchmark | BASE |
HEAD |
Change | |
|---|---|---|---|---|
| ⚡ | execute_80-20-rail |
3.8 s | 3.4 s | +11.69% |
| ⚡ | execute_gear-rack |
1.7 s | 1.5 s | +11.97% |
| ❌ | execute_socket-head-cap-screw |
1.6 s | 1.9 s | -14.92% |
… changes introduced by calculate_circle_center refactor
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6192 +/- ##
==========================================
+ Coverage 84.95% 84.97% +0.01%
==========================================
Files 108 108
Lines 45121 45169 +48
==========================================
+ Hits 38333 38381 +48
Misses 6788 6788
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rust/kcl-lib/src/std/utils.rs
Outdated
| let points_array = [[0.0, 0.33, 0.66], [0.0, 0.1, 0.2], [0.0, -0.1, 0.1], [0.0, 0.5, 0.7]]; | ||
|
|
||
| let get_point = |radius: f64, t: f64| { | ||
| let angle = t * 2.0 * PI; |
There was a problem hiding this comment.
Missed opportunity to use TAU. We're big fans of tau 🙂
There was a problem hiding this comment.
Oh, I see, I've updated that :)
* add tests for calculate_circle_center - the first one succeeds with the current impl * fix calculate_circle_center * comment cleanup * clippy * comment format * update circle_three_point sim test snapshot for slight floating point changes introduced by calculate_circle_center refactor * use TAU instead of 2 * PI * clippy
* add tests for calculate_circle_center - the first one succeeds with the current impl * fix calculate_circle_center * comment cleanup * clippy * comment format * update circle_three_point sim test snapshot for slight floating point changes introduced by calculate_circle_center refactor * use TAU instead of 2 * PI * clippy
* add tests for calculate_circle_center - the first one succeeds with the current impl * fix calculate_circle_center * comment cleanup * clippy * comment format * update circle_three_point sim test snapshot for slight floating point changes introduced by calculate_circle_center refactor * use TAU instead of 2 * PI * clippy
* main: #6182 Improve calculate_circle_center (#6192) make sure the nix flake never breaks (#6273) Add CSG operations to the artifact graph (#6104) refactor: Change to use topLevelModule helper function (#6264) Remove experimental warning on whole-module imports (#6240) Insert a newline between block comments and attributes (#6250) Remove import function from std (#6241) Fix vscode lsp bugs (#6271) bump kcl friends (#6272) Bump modeling api & pull thru csg endpoints (#6245) Franknoirot/adhoc/improve e2e (#6265) Fix URL encoded names after rename to Zoo Design Studio (#6269) Repetitive structs removed for import file extensions (#6211)
* add tests for calculate_circle_center - the first one succeeds with the current impl * fix calculate_circle_center * comment cleanup * clippy * comment format * update circle_three_point sim test snapshot for slight floating point changes introduced by calculate_circle_center refactor * use TAU instead of 2 * PI * clippy
Fixes #6182
This fixes the returned NaNs in this example kcl:
The existing implementation of
calculate_circle_centerreturned NaN because of division by zeros when 2 points had the same x coordinates resulting in Infinite slopes.I think instead of calculating slopes and handling special cases it's simpler and more robust to just solve the equations.
There are still edge cases like when the 3 points are collinear but that's handled now so at least it doesn't return NaNs.
A slightly different but still robust approach would be to still calculate the 2 bisectors and solving the line intersections.
Added some unit tests as well.
I think the intersect function could be reworked the same way without using slopes.