# Pig simulation

## The flying pig

To simulate the complete 3D motion of a flying pig is beyond what can be done simply with GeoGebra, but it is possible to model the circular motion in 2D defining the radius in terms of the frequency of rotation, so as the pig flies faster the circle gets wider.

Since writing this worksheet GeoGebra 5 has been released, this does have the option for 3D simulations like Spinning stopper simulation (GeoGebra)

### Circular motion

To model circular motion we need to define the x and y coordinates of a point using the equations for the horizontal and vertical components of displacement. Let's start by considering a particle of mass m travelling anticlockwise with constant speed in a circle of radius r. At some time t the particle is in the position below.

In this position the horizontal component and vertical components of displacement will be
x = r cosθ
y = r sinθ

If the angular velocity is ω, then θ = ωt so
x = r cosωt
y = r sinωt

But ω = 2πf so
x = r cos(2πft)
y = r sin(2πft)

Now we have the equations for the position of the particle at different times we can start to make a simulation. First open geogebra.

The first thing to do is to add sliders to define the variables radius, frequency and time.

• Select slider from options under the slider menu.
• Click on the graph where you want the slider to appear, this will open a box
• Name the slider r and set the minimum to 0 and maximum to 5, increment 0.1.

• The slider will appear, you can change its properties by double clicking.
• Right clicking the slider opens up options to fix position, hide, show, rename and delete.
• Make sliders for frequency (0 to 1 increment 0.1) and time (0 to 10 increment 0.1).

### Writing equations

Now you have defined the variables you can write the equations that will define the coordinates of a point.

• In the input bar at the bottom of the window type dx=r*cos(2*pi*f*t) when you enter this an equation will appear in the algebra pane.
• No write the equation for y displacement dy=r*sin(2*pi*f*t)

### Defining coordinates of a point

• Create a point by clicking the point button then placing the point somewhere near the origin.
• Define the position of the point by double clicking, this opens a window displaying the coordinates of the point, replace the coordinates with (dx,dy).

• You can now make the point move by changing the values of r, f and t using the sliders

### Animating the point

To animate the point you make t change automatically.

• Right click the t slider and choose properties.
• Under the basic tab tick animation on.
• Under the slider tab select animation > repeat > increasing.

• Start the animation by clicking the arrow located bottom left of the window.
• Vary f and r to observe the effect.
• You can make the point leave a trail by right clicking it and selecting "trace on".
• ctrl+ f removes the trace.

### Simulating the flying pig

When a pig flies on a string the radius of the circle is dependent on the angular velocity of the pig so we need to replace r with an equation. From the Flying Pig worksheet we know that h = g/ω2 but we want an equation for r. This can be obtained by applying Pythagoras to the triangle below.

L2 = h2 + r2

So

• Add a slider for L from 0 to 5 increment 0.0001
• Replace r in the equations for dx and dy with sqrt(L^2 - 9.8^2/(2*pi*f)^4)

Try varying f and the radius will also change but notice that the model doesn't work below small values of f. This is because the solution for r is the square route of a negative number. The equation only works for values such that L2 > g24 which is when L>h

This animation models the motion of a particle on the end of a string but doesn't really model the pig experiment. This is because the pig always travels with a constant speed (unless the battery starts to run down) so for each length of string there is only one possible frequency.

• To obtain a value for r input the equation r = sqrt(L² - 9.8² / (2π f)⁴)
• Calculate v by inputting the equation  v = 2*pi*f*r
• Display v by using the text tool.

To keep the pig at the same speed set L to 5m then vary f until v = 3 ms-1 . Now change L and adjust f so that v is again 3ms-1.

### 3D simulation

To make a 3D simulation you need to choose 3D graphics from the view menu.

• Calculate a value for h by inputting h = sqrt(L² - r²)
• add a text box for h
• Add a point to the 2D graph (this will be the top of the string).
• Change the coordinates of the point to (0,0,h)
• in the 3D view add a line segment joining this new point to the pig point.

If you still have access to the pig you could measure its speed then use this speed in the simulation to check your values.

• Test some of the simulation values to check that h = g/4π2f2

All materials on this website are for the exclusive use of teachers and students at subscribing schools for the period of their subscription. Any unauthorised copying or posting of materials on other websites is an infringement of our copyright and could result in your account being blocked and legal action being taken against you.