1

By no means I am a physics expert. I am writing an iOS (iPad to be precise) App which will present a door knob sign, hanging off a (surprise) door knob. What I need to accomplish is to simulate a pendulum effect on the sign whenever the device gets moved around using the accelerometer.

Is it necessary for me to use a full-blown physics engine for this? If so, which one would you recommend? Or can I just make use of a couple of well-known and defined formula?

As usual, thanks to you all.

Best,

boliva
  • 5,604
  • 6
  • 37
  • 39

2 Answers2

2

The physics aren't too bad for this. A great demo in Java exists here.

Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232
2

@Kevin Sylvestre's pointer gives a good explanation for calculating the pendulum motion once the pivot point and the starting head angle are set. What you should add to your simulation is a dependency of the initial angle on the magnitude of acceleration that is measured with the horizontal accelerometer. A very simple relationship is to set To = K*Ax, where To is the initial angle (Theta_zero), K is a proportion constant and Ax is the horizontal accelerometer measurement. Thus when an impact is sensed, the pendulum starts to oscillate in a magnitude relative to the impact.

ysap
  • 7,723
  • 7
  • 59
  • 122
  • Thank you all for your answers. Sorry it took me this long to get back to you, I moved into a new house and lots of stuff happened in between. Unfortunately I am no longer in need of implementing this, but I will keep it for future reference if the chance ever appears to have it made at some point in the future. Anyways, I am accepting your answer. – boliva Dec 20 '10 at 14:47