Python – Curve equation between two points, while curve limits are defined by two points

Curve equation between two points, while curve limits are defined by two points… here is a solution to the problem.

Curve equation between two points, while curve limits are defined by two points

I’ve been trying to find a way in python to calculate the equation of a curve that intersects exactly 90 degrees from the axis of their respective points, without the curve not exceeding the y value of the first point and the x value of the second point. As a visual effect, I’m trying to write some code to create equations for straight lines like this:

enter image description here

Is such a thing possible anyway? Thanks!

Solution

If I understand correctly, an ellipse centered at the origin and with the endpoints of the major and minor axes at a given point on the x- and y-axes will do. If the x-coordinate of a point on the x-axis is a and the y-coordinate of a point on the y-axis is b, the 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,

the equation

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

For 0 <= x <= a

Another way to get a smoother graph around x==a, is this a parameterization of 0 < = t < = math.pi / 2? :

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

Another more flexible solution is to use Bezier curves instead of ellipses, but this is more complicated.

Related Problems and Solutions