Get enough data to draw an arc or a curve from 3 points

bezier-curvecurvesgeometryinterpolation

Note: Although I want to accomplish this in java, I think the question is more suitable for this site since it is mostly mathematical.

I am in the following scenario. I want to draw a curve and I have the following points:

  • The starting point
  • The midpoint of the curve
  • The end point

And java allows me to create a curve from any of the following:

  • an arc with 2 points, the starting angle and the ending angle
  • an arc with center, radius, start angle and end angle
  • an arc with 3 points and the radius
  • Other curves of different types with 1 or 2 "control points", which I see that I do not have.

This Gimp screenshot shows roughly what I'm trying to achieve.

enter image description here

Edit: I clarify that I want to achieve the type of curves or arcs used in perspective to create circles. Next I leave a photo (it does not belong to me) to illustrate:

enter image description here

Edit 2:

One pattern I noticed, is that the curve is "enclosed" in a square formed by the first and last points. Below is a picture of an "ideal" curve:

enter image description here

What formula can I use to calculate any of those things?


Doing research, I found several questions that didn't serve my purpose (both here and on Stack Overflow) or I wasn't able to understand. Among what I found, I saw that you can get the center of an arc with bisectors as it says here, but I don't feel comfortable working with the long equations of the rect.

Best Answer

One way you can solve this problem is by using Bezier quadratic curves. The curve is given parametrically by

$ P(t) = P_1 (1 - t)^2 + 2 t (1 - t) P_2 + t^2 P_3 $

where $P_1$ is the starting point, $P_3$ is the end point, and $P_2$ is the point where the tangents to this (parabola) at $P_1$ and $P_3$ intersect.

You have $P_1$ and $P_3$ but you don't have $P_2$. Instead you have the midpoint of the curve at some $t \in [0, 1] $. Let's call this point $P_4$, so what you have is $P_1$ (start), $P_3$ (end) and $P_4$ (midpoint). What you don't have is $P_3$ and the value of $t = t_0$ at which $P(t_0) = P_4$.

Let your parameter be $t_0$, then

$ P(t_0) = P_1 (1 - t_0)^2 + 2 t_0 (1 - t_0) P_2 + t_0^2 P_3 = P_4 $

For example, we can take $t_0$ to be equal to $0.5$. Substituting this, we get

$ P_2 = \dfrac{ P_4 - P_1 (1 - t_0)^2 - t_0^2 P_3 }{2 t_0 (1 - t_0) } $

Since we've selected $t_0 = 0.5$ then

$ P_2 = \dfrac{ P_4 - 0.25 P_1 - 0.25 P_3}{0.5} = 2 P_4 - 0.5 P_1 - 0.5 P_3 $

Now that we have $P_2$, we can draw the curve $P(t)$ from $t = 0$ to $t = 1$.

Below are two examples of this method. The red points are $P_1$ through $P_4$ with $P_2$ being the calculated point and lies outside the curve while $P_4$ is the given midpoint.

enter image description here

enter image description here