# Move a point to another, along an elipse

according to this picture, I want to move my yellow object, smoothly to the red one. And I want to have an eliptic trajectory in relation to my center point.

So for now I'm having this code:

yellowPoint.position = Vector3.SmoothDamp(yellowPoint.position, redPoint.position, ref currentVelocity, dampingMove);


How can I change it to add the elipse, depending on a third center point ? the itinial code can change of course.

Thanks you !

• You may want to look at bezier curves instead. Could probably give you the result you want. Or do you want the movement to follow the curvature of the planet? In that case it's "just" moving along a section of a circle. – Morten Andersen Jan 23 '19 at 15:59
• What defines the ellipse that you want to follow? Do you possibly want to rotate from one point to the other while smoothly increasing/decreasing the radius? If so, this curve may correspond to an Archimedean spiral rather than an ellipse. Or are you trying to simulate orbital mechanics for a trajectory around a gravity well, or a maneuver to change the orbit? If so, it would help to know how scientifically accurate you're aiming to be — whether you just want a simple C1 smooth curve or need to simulate real acceleration/deceleration effects on the orbit. – DMGregory Jan 23 '19 at 16:26

There are multiple ways to do that, depending on what kind of curve you want.

For example bezier curves:

The logic behind them is that, you take three points that define your curve. The first point is the beginning of the curve, and the last one is the end of the curve. The other is a "control point" meant to give the curve its shape.

To calculate this, you need to be familiar with a function like Lerp, which is used to find a point that lies between two other points. Following that, you end up with this:

// The points of the curve
Vector3 P0, P1, P2;

// time going from 0.0f to 1.0f
float t;

Vector3 pointInCurve =
Vector3.Lerp(Vector3.Lerp(P0, P1, t), Vector3.Lerp(P1, P2, t), t);


The logic behind it is: Assuming you have a variable t that says at which position on the curve you currently are, find the point between P0 and P1, depending on t, so that in the beginning it's closer to t (so closer to P0) and as time passes, it goes closer to 1 (so closer to P1). Do the same for another point that goes from P1 to P2. These are the two green points illustrated on the gif.

Then do the exact same thing, for finding your desired point, which is now between the two green points. The result is the black dot on the gif, following the red curve/path.

Once you get the hang of how curves work, you can experiment with how fast t is updated to create effects like in easings.net.