# Smooth Eliptical Movement

Hi guys, i would need some help with movement on ellipse.

I am using basicequation for figuring out position on ellipse :

basically getting degree, converting that to radians and using radians to figure out posX and Y. Basic stuff.

degree += speed * Time;

But this results in non linear motion speed. I.e. it gets slower around the larger radius, but i would need the speed to be equal all the time ( means point on ellipse finish the 360 degrees in same amount of time as before but with equal speed ( step size ) all the way ).

Any help greatly appreciated.
Thank you
Zoltan

Last edited:

mfb
Mentor
You need some method to approximate the arc length.

I think this method would give reasonable results, and it is easy to implement:
do the same calculation as you do now, compared the distance between the old and the new point. Modify the increment for "degree" by its inverse value. (+some prefactor). This way, the speed is approximately constant, where the approximation is better for smaller step sizes.

Thanks for suggestion, tho i am not exactly sure how i would do that :) I don't how i would find distance between the two points, i think that finding direct distance wouldn't work, it would have to be distance on the elipse, which i am not sure how to do. I might would be able to figure that out for circle, but for ellipse i doubt it :(

But otherwise i think the solution could work as i would basically even the step size this way, but isn't there any clean way how to do it ? Because this would speed up basically the movement speed in overall, while i would rather need to have the point finish the ellipse in same time as before ( should have mention that before ). So it would mean it gets slower around Sin 0 and faster around Sin -1,1 ( for y radius larger than x radius ).

mfb
Mentor
i think that finding direct distance wouldn't work, it would have to be distance on the elipse
That's the point of small angles - for small angles, the line between the two points is not so different from a straight line.
I am not aware of an analytic way to do this, you will always need some approximation I think.

Because this would speed up basically the movement speed in overall
You can scale it with an appropriate (constant) factor to get the same time.

rcgldr
Homework Helper
The general method for constant speed c using cartesian coordinates:

y = f(x)
dy/dx = f'(x)
dy = f'(x)dx

using arc length formula:

c = ds/dt = sqrt(1 + (f'(x))^2) dx / dt

dx/dt = c / sqrt(1 + (f'(x))^2)

dy/dt = f'(x) dx/dt = c f'(x) / sqrt(1 + (f'(x))^2)

If the last two equations can't be integrated directly, then use numerical integration. Note that dx/dt could be ± c / ... and dy/dt could be ± c f'(x) / ... depending on the curve and the current position (x,y).

The same method can be used for polar coordinates:

r = f(θ)
dr/dθ = f'(θ)
dr = f'(θ)dθ

c = ds/dt = sqrt(r^2 + (f'(θ))^2) dθ/dt

dθ/dt = c / sqrt(r^2 + (f'(θ))^2)

dr/dt = c f'(θ) dθ/dt = c f'(θ) / sqrt(r^2 + (f'(θ))^2)

Last edited:
The general method for constant speed c using cartesian coordinates:

y = f(x)
dy/dx = f'(x)
dy = f'(x)dx

using arc length formula:

c = ds/dt = sqrt(1 + (f'(x))^2) dx / dt

dx/dt = c / sqrt(1 + (f'(x))^2)

dy/dt = f'(x) dx/dt = c f'(x) / sqrt(1 + (f'(x))^2)

If the last two equations can't be integrated directly, then use numerical integration. Note that dx/dt could be ± c / ... and dy/dt could be ± c f'(x) / ... depending on the curve and the current position (x,y).

The same method can be used for polar coordinates:

r = f(θ)
dr/dθ = f'(θ)
dr = f'(θ)dθ

c = ds/dt = sqrt(r^2 + (f'(θ))^2) dθ/dt

dθ/dt = c / sqrt(r^2 + (f'(θ))^2)

dr/dt = c f'(θ) dθ/dt = c f'(θ) / sqrt(r^2 + (f'(θ))^2)

thank you for your reply. But i am a bit lost in the stuff you posted :) Is this supposed to provide new positions for the point on ellipse or is it just evening out the increments, to make the speed constant (i.e. adjusting the position of existing point ) ?

If you would write down a bit more explanation on the cartesian coordinates solution i would be eternally grateful :)

Thanks again

LCKurtz
Homework Helper
Gold Member
@zoltan: Suppose you have an ellipse and a circle on the same graph, both centered at the origin. Say your moving points start at the positive x intercept of each. Do you want each point to move at its own constant velocity and complete one circuit at the same time? Or is it only important that they end at the same time, with the speed around the ellipse variable?

@zoltan: Suppose you have an ellipse and a circle on the same graph, both centered at the origin. Say your moving points start at the positive x intercept of each. Do you want each point to move at its own constant velocity and complete one circuit at the same time? Or is it only important that they end at the same time, with the speed around the ellipse variable?
I need them to move at its own constant velocity AND complete circuit at the same time :) I understand that if you would take speed same as on circle, you would get the point on ellipse finish faster, if it was constant speed, thus i would need the speed on ellipse also get slower while constant. But i really don't know how to go around it. So the problem isn't only to even out the speed, but also make it finish at the same time as before. I understand its quite a problem :)

chiro
Base it on the derivative of the function (how x and y change with respect to t) and scale it based on these.

mfb
Mentor
I need them to move at its own constant velocity AND complete circuit at the same time :) I understand that if you would take speed same as on circle, you would get the point on ellipse finish faster, if it was constant speed, thus i would need the speed on ellipse also get slower while constant. But i really don't know how to go around it. So the problem isn't only to even out the speed, but also make it finish at the same time as before. I understand its quite a problem :)
Calculate the total arc length of the ellipse first, and scale the motion based on that value.

Calculate the total arc length of the ellipse first, and scale the motion based on that value.
how i would do that ? :)

mfb
Mentor
With one of the formulas posted here, or one of the formulas in the linked websites.

rcgldr
Homework Helper
The general method for constant speed c using cartesian coordinates: ...
Is this supposed to provide new positions for the point on ellipse or is it just evening out the increments.
If the resuting equation for dx/dt can be integrated, and that equation inverted to produce a function of x based on time: x = X(t), then it gives you a direction solution to your problem If y is a function of x, then y = Y(x) = Y(X(t)). If this is not possible, you have to use numerical integration to calculate x and y based on increments of time (Δt).

I hope I get the math correct here, again using c for the constant speed:

x^2 / a^2 + y^2 / b^2 = 1
y^2 / b^2 = 1 - x^2 / a^2
y^2 = (b/a)^2 (1 - x^2)
y = ± (b/a) sqrt(1 - x^2)
dy/dx = - ± (b/a) x / sqrt(1 - x^2)

dx/dt = ± c / sqrt(1 + (dy/dx)^2)
dx/dt = ± c / sqrt(1 + (b/a)^2 x^2 / (1 - x^2))

See if you can complete the math from this point.

Last edited: