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

I was trying to find a way in python to calculate the equation of a curve of a curve that intersects the axis of their respective points by exactly 90 degrees, while the curve does not exceed the y-value of the first point and the x-value of the second point. As a visual one, I am trying to write code that creates an equation for a string like this:

enter image description here

Anyway, maybe something like this? Thank!

+3


source to share


1 answer


If you understood correctly, this would make an ellipse centered at the start and the ends of the major and minor axes at your x and y points. If a point on the x-axis has an x-coordinate a

and a point on the y-axis has a y-coordinate b

than the equation

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

      

If you need 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 a smoother near x==a

-by plot is parameterization for 0 <= t <= math.pi / 2

:

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

      

Another, slightly more flexible solution is to use a Bezier curve rather than an ellipse, but this is more difficult.

+3


source







All Articles