Recently, while flying between Durham and New York, I decided to take a picture of the propeller during take off. I don’t know what prompted to me to do this, but when I pointed my iPhone camera at the propeller out my window I noticed very odd pattens. I took multiple pictures throughout the flight with my iPhone, and in some cases at the same time took pictures/video with my Canon camera. To clarify the specs of the two cameras: I have an iPhone 3G (8 GB) and a Canon SD700 IS. As you will see in the pictures below, the iPhone’s picture simply makes no sense with the blades appearing to be disconnected vertical lines. The photo from the Canon seems reasonable, but as you will see in the video the propeller appears to be going fairly slowly, when in real life all I could see was a blur because of how fast it was moving.
Plane Propeller Photo from iPhone 3G
Canon SD700 IS Plane Propeller Photo
This got me thinking about why the images looked the way they did. I assumed they were related to frame rate and as a result wondered if I could work backwards to find the speed of the propeller. When I got back to Duke, I talked it over with some of my friends. We discussed one theory that explained the slow spinning in the video from my Canon. I later found out is similar to the Wagon-wheel effect, and will go into more detail on this later. We also discussed possible distortions and other possible causes but couldn’t figure out exactly what was causing the odd pattern in the iPhone photo. Eventually, I decided to search around the internet and found that I was not the only one to notice this oddity. I also stumbled upon this great post explaining clearly and graphically why the iPhone photo looks the way it does. In short, most cameras save pixels from all parts of the lens at once, while the iPhone camera goes through the lens saving pixels linearly over time, similar to watching a scanner save the page of a book. (If anyone has an iPhone 3GS and can snap a picture and/or video of a propeller, please let me know. I’m very intrested to see if Apple’s upgraded camera still behaves this way. Please let me know if you find out.) The writer of the post also demonstrated this in a cool video made from a Matlab script:
Personally, I think this is really cool so I decided to play around with it some more. As I mentioned earlier, my friends and I had discussed the wagon-wheel effect or the stroboscopic effect, so I thought I’d modify his script to demonstrate it more clearly since the Wikipedia pages on the twotopics both seemed a bit lacking. First, it is necessary to explain the general concept. The stroboscopic effect explains if you only see flashes or quick individual frames of a moving object at regular intervals you can get a distorted view of the motion, especially if the motion of the object that is being watched is cyclic or has a frequency. The relationship between the frequency of the flashes or frames and the frequency of the motion is what determines the perceived motion. The most common case of this is seeing a wheel which you know to be rolling forward, but it looks to be spinning backwards slowly. I modified the previous Matlab code to create a basic example of this with the propeller (download the code here). As you will see, the propeller on the left will spin counterclockwise at a moderate speed and every 8 frames the image on the right will update with a copy of the image on the left. This out of sync updating will make the propeller on the right appear to rotate clockwise.
Click the image to view the video
I also decided to show this more mathematically by plotting these movements in Mathematica. In the following examples I graph both the y-coordinate of the tip of the propeller and the angle that the blade has rotated in radians. In the graph of y the coordinate, there are three sinusoidal functions representing 3 propellers, each offset from the previous by 120 degrees (thus equally spaced). These lines and their colors correspond to the colored lines on the radian vs. time graph. The red lines mark a flash or frame and the dot on the line shows the top-most propeller. As you vary the spacing of the lines and thus change the frame rate, you can see the propeller will appear to stay still, then go backwards, then flip back and forth with no perceived motion, then go forwards, until it appears to stand still again. Below are pictures showing each of these stages, followed by a video fluidly showing these variations.
Here is the propeller appearing to stand still. This is due to the fact that the spacing of the frames is twice the period.
The graphs below show the propeller appearing to go backwards. Here we see that the frame rate is just below two periods of the propeller. The downward slope on the radian graph is a simple quick way to see the direction of the propeller rotation.
Propeller appearing to flip repeatedly:
This example shows the propeller appearing to rotate forwards. Again, the upwards slope of the points on the radian graph is an easy way to see the direction of rotation.
Last, here is the propeller appearing to stand still again. Unlike the first case of the propeller standing still, the spacing of the frames is not a multiple of the period. Rather, we see here that it is a multiple of 1/3 the period. It is only necessary that the spacing be a multiple of 1/3 the period because there are three blades and the blades are indistinguishable.
And finally, putting it all together:
The Mathematica code can be viewed here or downloaded here, and a printout of the entire Mathematica worksheet can be found here. Last, if one had a camera which could vary the frame rate just so slightly as to find two nearest frame rates to show the propeller standing still, the frequency of the propeller could be calculated as shown below.
As for the iPhone picture, a single image (and knowing the number of blades) is enough to roughly approximate the speed of the propeller as shown below.
However, just as a warning both of these are back of the envelope calculations and it is very possible I made a mistake (if so please let me know). That is all for now. Nothing ground breaking, but as the title suggests, it was a good chance for some mental masturbation, playing with Mathematica and Matlab.
I got an e-mail this morning from someone who saw my post on Twitter about using LDAP on the iPhone here at Duke. The person said they followed the tutorial but couldn’t quite get it to work. So I figured it may be useful to post a few quick instructions on setting it up. As the post on Twitter explains, the basic instructions for getting to adding an LDAP account can be viewed here and Duke’s LDAP server settings can be found here. Once you are set to add the LDAP account, simply set the server to ldap.duke.edu, no need for a username or password. Once you click next you will want to turn off SSL and change the Search settings for duke,edu to have a base value of “ou=People,dc=duke,dc=edu” (leave the scope at subtree). And that’s it. To use it, which turned out to be the issue for the person emailing me, go to write a new email and start to type in the name of the person to search. You should see a throbber show up at the top of your screen, showing that it is connecting to the server. There is a bit of a lag but it should eventually return the contacts for people by that name. Below are some pictures of the settings and the search. Let me know if you run into any issues.
A couple of weeks ago I decided to give Google Reader a try. I have been addicted to Netvibes for at least 2-3 years now, but I saw that Reader had a more active community around it, so I thought it was worth trying out. Almost immediately I disliked the look and feel. I am subscribed to over thirty fairly active RSS feeds and in Reader it was hard to see which blogs had new posts. The default action is to just look at a long list and viewing posts by blog is almost hard to do. As a result “Mark[ing] all as read” for a specific blog takes many more scrolls and clicks, which had been extremely easy in Netvibes. About this time I was giving Mozilla’s Jetpack a try and found the Google Reader Notifier, which would notify me via Growl of new posts. So I decided to give Reader a longer try, despite some initial disappointments.
Ultimately, I became addicted to these near instant updates for new blog posts that the Jetpack extension provided. At the same time I learned to love the fact that by default I was forced to read the title for every blog post in Reader. Where as before in Netvibes I would never scroll through the backed up posts from Gizmodo and Engadget, Reader’s chronological ordering makes me go through each post. Recently, this is just another case where what I think I want does not match up with what actual creates a better user experience (similar to Google’s analysis of users searching more with 10 results despite asking for as many as possible or Dan Curtis’s explanation that we are not in control of our deicions). Also, this reminds me of Aza Raskin’s statement “Every time you make the user make a decision they don’t care about, you have failed as a designer.” Interestingly, Google forced me to make a harder decision than I wanted to make; where before I could avoid deciding whether or not to remove the blog by just leaving it on my page and just easily clicking away new posts with “Marking all as read,” I now had to decide to either read the post titles or make the leap to get ride of the RSS feed all together. While I was able to be lazy before, it made for a more concrete decision and user experience.
The other thing I realized was that the Jetpack extension for Reader notifications was causing my browser to hang when I had a bad internet connection. Sadly, living in an off campus apartment with spotty Internet this happens all too often, and I decided to disable Jetpack. However, I missed the notifications and decided to fix the Jetpack extension. I reworked the old extension to only perform asynchronous AJAX calls, getting rid of the browser hanging issue, and modified the extension to display notifications to show new posts by blog title, thus making the notifications more informative. The status bar display and the new Growl notifications can be seen below. Click here to install this extension or here to view the code. Of course, let me know your thoughts or any bugs you run into. Thanks.
Also, as some friends like Niru, DJ, and Marc have pointed out, I have somewhat decreased my blogging but have been posting a good number of posts on Twitter. So of course, you should follow me on Twitter here.
For the past few months I have been following the progress of Chromium for Mac and watching it develop and it has definitely made a lot of progress in that time. In the past few month it has received increasing press, with people asking why it is taking so long. One of the lead developers on the project responded that people need to chill out and that building a browser takes time. So, in part to show myself and others the progress, I decided to make a little application to show this progress. Throughout the day builds and updates of Chromium are posted to http://build.chromium.org/buildbot/snapshots/sub-rel-mac/ but to read each changelog was a pain. So, to give myself more exposure to new Python libraries and give the Twitter API a swing, I created a script to check for changes to the builds, pull log entries on the changes and post them all to a Twitter stream so there is a single source you can view updates. The script is far from perfect, as it has to be running to catch the updates and doesn’t go back and look for ones it missed. And currently I just have it running on one of Duke’s servers so it goes down occasionally. But it generally works and provides plenty of updates so you can see what is actually be worked on and updated. Check out the source code below (twitter username and password cut out).
As usual I haven’t posted in a while but there actually have been some things going on that may be worth writing on here. I’m at Duke for the summer doing research with the Physics Neutrino group, among other things so here are some things that have happened:
Ethical Hacking Seminar
Duke OIT gave me the opportunity to take this hacking seminar at Duke the first week of summer. It was definitely an extremely beginner course and I was a little disappointed to see that so much of it was just “pick the right tool and run it,” but good opportunity to dig a little deeper into network protocols and learn some new things; without a doubt was worthwhile. If anyone reading this is as much of a beginner as I am check out things like Ettercap, nmap, and Nessus.
Duke’s AFS Online Interface – Webfiles
The past year I have been working with OIT, half doing web application security and half doing programming updating Duke’s online interface for its AFS file system, Webfiles. Essentially, it was an attempt to make the online interface more comfortable for average users and make it most similar to Windows Explorer and OS X Finder so that using it is as intuitive as possible. The coding was anything but beautiful, but it was a good opportunity to learn more about Javascript and play with some fun things. General changes are that it now has an icon and outline view, drag and drop, some of the typical shortcut keys, etc. Below are some screenshots and I will try to create a demo site at some point. I am also excited to say Duke is making all my code open source so let me know if you would like to implement it yourself. I believe Carnegie Mellon is currently looking at deploying it on their systems, which I think is exciting.
Neutrino Physics
I just started working with Professor Chris Walter and his Neutrino Physics group. So far, just to get into the group, I have been working on creating a plug-in for ROOT to make it read and write to a specific kind of distributed file system faster. It has been an interesting experience getting back into C++ and a little bit of Fortran, and learning about this large project out of CERN. I’m still finishing up the plug-in but hopefully I will be able to post the code or at least write about how to easily integrate the plug-in into ROOT when I’m done. Not sure what I will be doing after that; I am taking classes on GEANT4 and think I will be doing monte carlo simulations of some sort for the rest of the summer, but I will write about this when I know more.
Simple Flash Cards in Python
The second reason I am here for the summer is that I need to take Spanish to fulfill Duke’s foreign language requirement. If you actually know me, you will know that I am horrible at foreign languages and have been dreading taking these classes since I got to Duke. It has now been two years since I last took a Spanish course, so jumping back into the language has been an interesting experience. Also, Spanish 63 is known to be a lot of work and over the summer its so jam packed together that it is actually a good amount of work each night. Anyway, we had our first test last Friday, and I had about 100 words of vocabulary to memorize, one of my worse skills. So, both to procrastinate from actually studying and because I thought it could be useful, I decided to make a basic command line flash card program. I’m trying to bit by bit pick up Python, so I used it and it was fairly simple. The program essentially takes in a plain text file with the two sides of the flash card on one line, each side separated by a colon. It then goes through the lines, shows you the second half of the line first, waits for you to press enter and then shows you the first half. If you press enter again it will discard the word and go to another random word in the deck; if you type ‘x’ and then press enter it will put the word back in the stack. Fairly basic, and the code is nothing special; probably took about 15 minutes to throw together, but it was surprisingly very useful as I could run through a lot of the vocab very fast and repeatedly. I’ll probably update it to make it a little better packaged together with proper arguments, etc. so you can check back for that. Anyway, to run it (if you have a Mac python is installed by default and in Windows you need to do it yourself) open up a terminal and make sure you are in the folder where the code and the text file with the vocab are. Then just type:
#!/usr/bin/env python# encoding: utf-8importsysimportrandomimportosdef clearscreen(numlines=100):
ifos.name == "posix":
# Unix/Linux/MacOS/BSD/etcos.system('clear')elifos.namein("nt", "dos", "ce"):
# DOS/Windowsos.system('CLS')else:
print'\n'* numlines
def main(argv=None):
if argv isNone:
argv = sys.argv
allLines = []
again = 'x'if(len(argv)>2):
again = argv[2]
f = open(argv[1], 'r')for line in f:
allLines.append(line)
clearscreen()
cnt = 0
wrong = 0
wWords = []whilelen(allLines)>0:
cnt += 1
l = allLines.pop(random.randint(0, len(allLines)-1))
parts = l.split(":")
p = 1
p2 = 0print cnt, "(", len(allLines), "). ", parts[p]
inp = raw_input("")if(inp == "exit"):
breakprint parts[p2]
inp = raw_input("")if(inp == "exit"):
breakif(inp == again):
allLines.append(l)
wrong += 1
wWords.append(l)
clearscreen()
clearscreen()print"Missed ", wrong, " times"for line in wWords :
print line
if __name__ == "__main__":
sys.exit(main())
Again, nothing special or fancy, but seemed to work well; I guess I’ll know how effective it was when I get the test back haha. Anyway that is all for now, I may make public a post I wrote a few months ago that I never published, so check for that and I’ll write of any other things I do this summer. Also check my twitter as I post more frequently there. Time to go outside.