Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equation of a curve between two points whereas the curve limits are defined by the two points

I've been trying to find a way in python to calculate an equation of a curved line that intersects the axis of their respective points at exactly 90 degrees whereas the curve does not exceed the y-value of the first point and the x-value of the second point. As a visual, I'm trying to write some code that creates an equation for a line like this one:

enter image description here

Is there anyway that something like this would be possible? Thank you!

like image 996
Fairly Factual Avatar asked Nov 18 '25 01:11

Fairly Factual


1 Answers

If I understand you correctly, an ellipse with center at the origin and ends of the major and minor axes at your given points on the x and y axes would do it. If the point on the x-axis has the x-coordinate a and the point on the y-axis has the y-coordinate b than an equation is

x**2/a**2 + y**2/b**2 == 1

If you want a functional equation that calculates the y-value from the x-value,

y = b * math.sqrt(1 - (x / a) ** 2)

which works for 0 <= x <= a.

Another way to get the graph that is more smooth near x==a is this parameterization for 0 <= t <= math.pi / 2:

x = a * math.cos(t)
y = b * math.sin(t)

Another, somewhat more flexible solution is to use a Bezier curve rather than an ellipse, but that is more complicated.

like image 115
Rory Daulton Avatar answered Nov 20 '25 18:11

Rory Daulton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!