문제

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,

도움이 되었습니까?

해결책

@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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top