Department of Mathematics
Dr. Kyle Claassen
Kyle Claassen
Assistant Professor of Mathematics

Office: Moench FL104
Office Hours (Winter 2024-2025): MTRF 4:00-5:00 and by appointment.

Wiimote Planimeter

Introduction

A planimeter is a mechanical device used to measure the area of a region based on its boundary curve. They are designed to exploit the remarkable formula $$ \text{Area}(D) = \frac{1}{2} \oint_{\partial D} x \, dy - y \, dx, $$ which is easily shown using Green's Theorem. Naively discretizing this particular line integral (though it isn't difficult to show rigorously) gives a formula that computes the exact area of an $n$-gon whose vertices $(x_0,y_0)$, $(x_1,y_1)$, $\ldots$, $(x_{n-1},y_{n-1})$, $(x_n,y_n) := (x_0,y_0)$ are ordered in a counterclockwise orientation: $$ \text{Area}(n\text{-gon}) = \frac{1}{2}\sum_{i=0}^{n-1} \left[ x_i y_{i+1} - y_i x_{i+1} \right]. $$ So, if we can capture a positively-oriented set of points tracing the boundary of a curve, then we can approximate the area of the enclosed region with the above formula.

The Device

A Nintendo Wiimote works by sensing an infrared light source, interpreting the location of the source in its internal coordinate system, and transmitting the coordinates to the base station via bluetooth. In typical use, the "sensor bar" provides the infrared light source. (It doesn't actually "sense" anything!) Fortunately for us...
  1. Hackers have reverse-engineered the Wiimote's communication protocol and have developed libraries for interfacing to it with a standard computer. See, for example, cwiid for Python on Linux (what I used for this project) or WiimoteLib for C# .NET on Windows. (I originally learned with this more years ago than I'd care to admit.) See also the inspirational projects by Johnny Chung Lee.
  2. In lieu of a "sensor bar", we can use our own infrared light source (see "infrared pen" below) to trace the boundary while recording the locations of the light source.
(Hooray!)

Infrared LEDs are inexpensive and are easy to obtain. (Or tear out of an old TV remote control.) A simple push-button switch will do the trick.

Prototype infrared pen Finished infrared pen
Prototype infrared pen Finished product

It will be important to hold the Wiimote in a fixed position while using the infrared pen to trace the region, so a mini tripod is helpful.

Wiimote on tripod Wiimote on tripod aimed at board Infrared pen tracing picture on board
A piece of cardboard is fixed to the tripod via screw/nut, and the Wiimote is held to the cardboard by velcro. (Very Fancy.) The Wiimote is aimed at a region whose area is to be determined. A bounding rectangle of known dimensions are used to calibrate and convert the Wiimote coordinates into physical coordinates suitable for measuring real area. The infrared pen is held in such a way that the light is visible to the Wiimote and is moved counterclockwise around the curve while coordinates are recorded.

The Wiimote probably won't be positioned squarely level with and orthogonal to the board, so its view will be a bit skewed. This can be corrected by using a four-point perspective transformation, which is calibrated using the corners of the rectangle with known dimensions. Basically, the rectangle looks like a more general quadrilateral to the Wiimote, but this perspective transformation will map it back to the rectangle we want with the appropriate scaling so that the measured areas are meaningful.

Calibration screenshot

Here, the bounding rectangle had dimensions of 30 inches by 30 inches.

Demo

Of course, I had to show it off. In addition to presenting it to my Calculus III students in Fall 2016/Spring 2017, I was invited to demo it to the Honors Calculus III class led by Professor Estela Gavosto and fellow Graduate Teaching Assistant, Peter Lewis in Spring 2017. Here are some Very Nice pictures from that demo!

Picture from demo Picture from demo
Picture from demo Picture from demo

The area of the smiley that day was about 230.6 square inches, apparently. This region is not simply connected, but Green's Theorem still applies if tracing it appropriately!

Completed demo screenshot

Neat!!