I'm attempting to plot the equation y = log(29.565ln(x) - 4.4898) on a JavaScript canvas. The challenge lies in determining the control points for a cubic Bezier curve that accurately represents this equation between specified starting and ending points. My starting x is 1.64003, starting y is -4.07205084, ending x is 4, and ending y is 1.562245182.
I've explored various approaches, including using cubic Bezier curves and attempting interpolation with Bernstein polynomials. However, these methods haven't produced accurate critical points or control points for the curve.
Additionally, I've considered the idea of finding the point of maximum curvature to split the curve into two quadratic Beziers, but I'm unable to devise a program that accurately determines the maxCurv point.
Here are two snippets showcasing my attempts:
- Cubic Bezier after the first approach.
- Two quadratic Beziers joined at the point of maximum curvature.
I'm seeking guidance or alternative approaches to accurately plot this equation on a JavaScript canvas, ensuring that the plotted curve aligns closely with the function's behavior between the specified starting and ending points. Any insights, methods, or strategies to achieve this would be greatly appreciated. Thank you!
Just plot your function by drawing a path on the canvas. No need to approximate anything:
(I'll leave padding the canvas, adding and labeling the axes, and putting the right unit values along those axes for you to do)
Do note, though, that your claim that "My starting x is 1.64003, starting y is -4.07205084, ending x is 4, and ending y is 1.562245182" is incorrect: assuming that
logis the base-10 logarithm function andlnis the base-e logarithm, those are not theyvalues you'll get for thosexvalues. You'll start aty=1.0058852487205416and end aty=1.5617255645804091.