1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Smooth Eliptical Movement

  1. Aug 12, 2013 #1
    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;
    radian = (degree/180.0f) * Mathf.PI;

    posX = Mathf.Cos(radian) * circleRadiusX;
    posY = Mathf.Sin(radian) * circleRadiusY;

    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
    Last edited: Aug 12, 2013
  2. jcsd
  3. Aug 12, 2013 #2


    User Avatar
    2017 Award

    Staff: 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.
  4. Aug 12, 2013 #3
    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 ).
  5. Aug 12, 2013 #4


    User Avatar
    2017 Award

    Staff: Mentor

    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.

    You can scale it with an appropriate (constant) factor to get the same time.
  6. Aug 12, 2013 #5


    User Avatar
    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: Aug 12, 2013
  7. Aug 13, 2013 #6

    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
  8. Aug 13, 2013 #7


    User Avatar
    Science Advisor
    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?
  9. Aug 14, 2013 #8
    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 :)
  10. Aug 14, 2013 #9


    User Avatar
    Science Advisor

    Base it on the derivative of the function (how x and y change with respect to t) and scale it based on these.
  11. Aug 14, 2013 #10


    User Avatar
    2017 Award

    Staff: Mentor

    Calculate the total arc length of the ellipse first, and scale the motion based on that value.
  12. Aug 14, 2013 #11
    how i would do that ? :)
  13. Aug 14, 2013 #12


    User Avatar
    2017 Award

    Staff: Mentor

    With one of the formulas posted here, or one of the formulas in the linked websites.
  14. Aug 14, 2013 #13


    User Avatar
    Homework Helper

    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: Aug 14, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Smooth Eliptical Movement
  1. Movement of markets (Replies: 2)

  2. Data Smoothing (Replies: 4)