spin a wheel and have it slow down and dampen

Discussion in 'iPhone/iPad Programming' started by Chirone, Jan 30, 2013.

  1. macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #1
    Hi, I have a view that I want to spin on the z axis and if you swipe your finger fast enough it should continue to spin and slow down, much like the scroll views do.

    I'm having a lot of trouble trying to figure it out. I've seen some people do it before but the result they get isn't really all that good. Like, the view spins like it should only if you swipe in a particular direction.

    All I've successfully been able to do is have the view rotate for a set time and set angle. I don't know how to calculate the time and angle based on the speed of the finger.
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    Look up "ease in ease out."
     
  3. thread starter macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #3
    That will make it slow down as it stops yes, but it's not the solution I'm looking for.
    It relies on me already knowing the start and end angles and the duration. The last two of which I don't know as mentioned in the last sentence of my first post
     
  4. macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #4
    Wwdc session advanced scroll view showed how to use a scrollview to act as the the gesture recognized. Using its delegate methods and the like to provide the sort info you want then apply that data to an OpenGL scene at frame rate.

    Might be worth a look.
     
  5. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    Shouldn't you be able to calculate (and so know very quickly afterwards) those two variables as soon as the user picks up their finger?
     
  6. thread starter macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #6
    Which year was that?

    Sure can! But I don't know how to calculate it...
     
  7. macrumors 603

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #7
    Well, you have the current speed and (I assume) a constant deceleration, so calculating the time it should come to a stop isn't hard. The position it'll be at that time can be found by taking the initial speed, dividing by 2, and multiplying by that end time.
     
  8. macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #8
    2012. Session 223 enhancing user experience with scroll views
     
  9. thread starter macrumors 6502

    Joined:
    Mar 2, 2009
    Location:
    NZ
    #9
    Cool. Will have a look.

    Also, I found this website:
    http://gizma.com/easing/

    it looks like the formulas should work. But it appears only the ease in and linear ones work. The ease out and ease in and out ones don't.
    Since ease in/out never looks different to linear to me I have to plot the values calculated on a graph and the values calculated for ease out are linear.
     

Share This Page