We can use the pin notebook to capture the position and time in space of the pendulum.
pics = {}; Pause[10]; Do[AppendTo[pics, {AbsoluteTime[], CurrentImage[]}];
Pause[0.1], {i, 120}];
All we need is the section of interest of the frames for the experiment, so using the ImageTrim functionality we can just keep the part of the frame that captures the movement of the golf ball.Using image processing functions, we can reduce the image to the components that will be key to obtaining the centroid of the ball.
pics2 = ImageTrim[pics[[#, 2]], {{50., 0.}, {305., 85.}}] & /@
Range[Length@pics];
Manipulate[DeleteSmallComponents@ChanVeseBinarize[Dilation[Blur[pics2[[i]], 5.5], 2],"TargetColor" -> Yellow], {i, 1, Length@pics, 1}]
Manipulate[
Show[pics2[[i]], Graphics[{Red, PointSize[Large], Point[Mean@ComponentMeasurements[DeleteSmallComponents@ChanVeseBinarize[Dilation[Blur[pics2[[i]], 5.5], 2],"TargetColor" -> Yellow], "Centroid"][[All, 2]]]}]], {i, 1,Length@pics, 1}]
times will be used to hold the amounts of seconds that have passed sinced we captured the first frame, positions will be holds the centroid location in pixels.
firstFrame = pics[[1, 1]];
times =
pics[[All, 1]] - firstFrame;
positions = Mean@ComponentMeasurements[DeleteSmallComponents@ChanVeseBinarize[pics2[[#]], "TargetColor" -> Yellow], "Centroid"][[All, 2]] & /@ Range[Length@pics];
Let's graph the horizontal position of the ball based on the lapsed time.
ListPlot[Transpose[{times, positions[[All, 1]]}], Joined -> True,
AxesLabel -> {"Seconds", "Horizontal Distance\n(pxls)"}]
Clearly a periodic function. There are 5 peaks between 0 and 6.3 seconds (2 Pi). The period of the function is around 5.
Let find an equation that fits the calculation.
sol = FindFit[Transpose[{times, positions[[All, 1]]}],
a Cos[b x + c] + d, {{a, 100}, {b, 5}, c, d}, x, MaxIterations -> 1000]
(*{a -> 99.7899, b -> 5.19945, c -> -0.239585, d -> 127.879}*)
Show[ListPlot[Transpose[{times, positions[[All, 1]]}],
AxesLabel -> {"Seconds", "Horizontal Distance\n(pxls)"},
PlotStyle -> Red, Joined -> False],
Plot[a Cos[b x + c] + d /. sol, {x, 0, 17}]]
The equation that fits the bill and the period of the function are:
(a Cos[b x + c] + d) /. sol
(*127.879 + 99.7899 Cos[0.239585 - 5.19945 x]*)
T = 2 \[Pi]/b /. sol
(*1.20843*)
Wikipedia has all the details on the modelling of the simple pendulum experiment.
http://en.wikipedia.org/wiki/Simple_pendulum which shows that the equation that relates the period with the length of the pendulum is given by.
Solve[Period == 2 \[Pi] Sqrt[L/g], g]
(*{{g -> (4 L \[Pi]^2)/Period^2}}*)
Our measurement of the length was as follows.
If we plug the numbers in then we get.
g = 4 \[Pi]^2 0.364/T^2
(*9.84047*)
Checking WolframAlpha
which is 0.5% error.