[23_27] Fix bugs when drawing semicircle #2212
Merged
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.
What
Fix 2 little bugs.
Why
When drawing an arc, we first select the circle center
![image](https://private-user-images.githubusercontent.com/2352485/400128989-af809f31-24bc-4a44-a4cf-2beae33fd9b4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MzI4NDksIm5iZiI6MTczODgzMjU0OSwicGF0aCI6Ii8yMzUyNDg1LzQwMDEyODk4OS1hZjgwOWYzMS0yNGJjLTRhNDQtYTRjZi0yYmVhZTMzZmQ5YjQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDZUMDkwMjI5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MWYyYmM5NDQ4NDNkOTkxMDFlOTJmNzU2MTUxNTI4ZjQzNWI1ZmJjZGRlNGYxNGZhNmRlNjhmNDNhODgzM2IxZSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.GuOVclK5d6VZqaM6SLe0JHDSEcPoC-rHjtTpVNXXCqc)
c
, then the start pointp
and end pointx
on the arc.It will use these points to calculate a third point
m
on arc, and usep
,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
andvec-c-q
is 180.In the previous code, it uses
vec-c-p
as the third pointm
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:
Fixed:
![image](https://private-user-images.githubusercontent.com/2352485/400129018-18d8c93a-d491-4d8d-843c-59d31298bd3d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg4MzI4NDksIm5iZiI6MTczODgzMjU0OSwicGF0aCI6Ii8yMzUyNDg1LzQwMDEyOTAxOC0xOGQ4YzkzYS1kNDkxLTRkOGQtODQzYy01OWQzMTI5OGJkM2QucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIwNiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMDZUMDkwMjI5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MzU0NDUyOGM4ZmI5ZmRkNTlkYTZjNjNkZTc2YjAyNjM1OGFkOTFkMGY3ODUzMGJmYWIyN2Q1YzNkYzVlODcwNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.IDgQsiAlj0GQU5xePocO2n9lkenD3pc4qOtRlkqSgmc)
The distance of
c
andq
asr1
is used to avoid the exception message in console, likeHow to test your changes?
Add a unit test so I can test it by
xmake run 23_27