[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
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:
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