Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[23_27] Fix bugs when drawing semicircle
<!-- Thank you for your contribution! --> ## What Fix 2 little bugs. 1. Can not draw the correct semicircle in current environment. 2. There will be "division by zero" exception in console when you're choosing the third point and move mouse to center point (the first point). ## Why When drawing an arc, we first select the circle center `c`, then the start point `p` and end point `x` on the arc. It will use these points to calculate a third point `m` on arc, and use `p`, `m`, `x` to draw the arc. By default it's counterclockwise though it's called "Std-arc". When we want to draw a semicircle, the angle between `vec-c-p` and `vec-c-q` is 180. In the previous code, it uses `vec-c-p` as the third point `m` incorrectly. We should still consider it's clockwise or counterclockwise here and then add the correct vector to the center point as the third point. Before: <img width="359" alt="image" src="https://github.com/user-attachments/assets/af809f31-24bc-4a44-a4cf-2beae33fd9b4" /> Fixed: <img width="361" alt="image" src="https://github.com/user-attachments/assets/18d8c93a-d491-4d8d-843c-59d31298bd3d" /> The distance of `c` and `q` as `r1` is used to avoid the exception message in console, like ``` ;/: division by zero, (/ 0.0 0.0) ; (let ((n (length opts))) (cond ((= n... ; D:\mogan\build\packages\app.mogan\data\progs\kernel\library\base.scm, line 270, position: 0 ; (let ((n (length opts))) (cond ((= n 0) (... ; f: 0.0 ; (f2s (/ (point-get-x pt) f)) ; pt: (point "0.0" "0.0") ; (list-values 'point (f2s (/ (point-get-x ... ; std-arc-helper: (equal? (point-get-unit v... ; vec-c-p: (point "2.0" "0.0") ; vec-c-q: (point "0.0" "0.0") ``` ## How to test your changes? Add a unit test so I can test it by `xmake run 23_27`
- Loading branch information