[Math] Pendulum with moving pivot

physics

I'm making a game which you can see here, if you are on Windows or Linux: http://insertnamehere.org/birdsofprey/

If you click and hold your mouse on a bird, you can see I'm just swinging the bird back and forth in pendulum motion. I would like to, instead, implement a more realistic motion, where the movement of your mouse affects the swinging of the bird like a pendulum with a moving pivot.

I found a document on this topic but the equations rely on knowing the pivot's acceleration (X'' and Y''), which I do not; I am only repeatedly translating the bird graphic to the current mouse position.

I have the bird's angle (-180 to 180 degrees), angular velocity and acceleration. I will need to alter these three variables each time the mouse is moved, so I will also have the last (x,y) and the new mouse (x,y).

Is this enough to make a good simulation of a pendulum with moving pivot?

Best Answer

In case you really need to simulate accurate physics, you can use the solution given below.

alt diagram

In the picture above, vector $A = g-a$ where $g$ is acceleration due to gravity, and $a$ is the acceleration of mouse which you need to compute in real time. You will have to translate $g=9.8m/s^2$ into $pixel/s^2$ and store as a constant. For $A$, you need to calculate $A_x$ and $A_y$ based on the last two frames.

We need to find $\alpha(t)$.

We have $\beta=tan^{-1}\frac{A_x}{A_y}$ and $A_1=|A|\cos(\alpha-\beta)$. Angular acceleration will be $-A_1/h$ ($h$ will vary from bird to bird).

You will need to solve the differential equation $\frac{d^2\alpha}{dt^2}=A_1/h$ in real time to make the bird swing realistically.

The obvious way to solve the differential equation numerically is given below -

Store angular velocity $\omega=\frac{d}{dt}\alpha$. At each frame of the animation, assuming $\Delta t$ time has passed since last frame, do

  1. $\omega\leftarrow\omega+\frac{A_1}{h}\Delta t$
  2. $\alpha\leftarrow\alpha+\omega\Delta t$
Related Question