Plotting curve by 2 points and their 2 tangents #8
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.
The implementation is based on Bézier curve
See https://en.wikipedia.org/wiki/B%C3%A9zier_curve
The curve is being plotted by 3 arguments!
1 - a point of start of the curve (x,y);
2 - a point of the end of the curve (x,y);
3 - two tangents to 1-2 points (tan_l,tan_r);
The main idea is based on intersections of tangents on the third point.
The intersection is calculated by the solved system of the line equations.
This implementation uses fixed-point arguments for calculating trigonometric functions.
Pay attention to arguments tan_l and tan_r!
You may choose the angle(in radians) from the angle the range [0;2*PI] which is equal [0;2^16] in fixed-point.
For example, your angle is 13 degrees: 0.2269 rad -> 2367 is the argument!
See algorithm https://www.logre.eu/wiki/Trigonom%C3%A9trie_en_virgule_fixe
This move has given us a significant increase in velocity and accuracy.
The results(tangent values) have been saved in "accum" fixed-point type data for further calculations.
The next step - drawing!
The drawing is based on Bresenham's algorithm by 3 points.
See https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm