Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting curve by 2 points and their 2 tangents #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kuzhylol
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant