A new app, yet not so new (galimber)

Being relatively housebound this week, I dragged out an old document I wrote 50 years ago (1970) in hopes that I could port some ancient software to the Makerphone.

In 1970, my employer asked my recently graduated engineer self how to project a 3-D solid object represented by a wire frame onto a screen such that the hidden lines would be, well
 , hidden. Sounded simple enough, but remember in 1970 we didn’t have any tiny graphic chips with OpenGL embedded on them; in fact OpenGL itself was more than 20 years in the future. And the projectors we were talking about couldn’t do raster graphics, only monochrome line drawing (in the spirit of today’s laser light shows.)

My research led me to a paper in the Communications of the ACM by R. Galimberti and U. Montanari in Milan entitled An Algorithm for Hidden Line Elimination which you can read here: Galimberti.pdf. I wrote a FORTRAN program that implemented that algorithm, a rather large box of punched IBM cards. It worked out well for the application my employer required, but could not, even on a powerful mainframe, do the projections (with hidden line elimination) in real-time. The box of cards is long gone, but I had managed to recreate the implementation in C years later based on a FORTRAN listing, and wrote a Windows program to show it off; with modern PC hardware, the algorithm could easily generate many frames per second in response to real-time changes in the orientation of the object.

So this brings us to the app, which I call galimber, and which you can get from this zip file: galimber.zip (668.5 KB) . Just unzip the file and copy the directory galimber to the root of your Makerphone’s SD card (do not rename it
 it must be named galimber). Replace the SD card in the phone, power it up, and among the app icons, you’ll find one that looks like a green abstract object. Run that app. When loaded, it will ask you to select from one of 7 wire-frame objects to be used as input to the algorithm. I suggest you start with SAMPLE and try the others at your leisure.

Once an object has been selected, it will be displayed as a 2-dimensional projection (with hidden line elimination) of the 3-dimensional object rotating about 3 axes. While the object is rotating, you can change the speed of rotation about each of the 3 axes as follows:

Left function button: decrease the increment for angle psi
Power button: increase the increment for angle psi
Home button: decrease the increment for angle theta
Right function button: increase the increment for angle theta
Asterisk button: decrease the increment for angle phi
Hashtag button: increase the increment for angle phi

Each button press increases or decrease the corresponding angle increment slightly, affecting the rotation.

The program can be restarted by pressing the A button.
The program can be terminated by pressing the B button.

Note: the object HELO is incorrectly defined in its object file, but I’ve never had the energy to find the problem and fix it. The algorithm depends on the object being perfectly defined, so this one will not render correctly at every angle.

Once I make the source code presentable (much of it is VERY old), I’ll publish it here. It compiles and links using the Arduino IDE.

I promised the source code for app galimber. There are 3 source files, galimber.ino, galimber.h, and galimber.cpp. They are too large, in total, to list here (or so this BBS tells me), so here they are in a zip file: galimber-src.zip (9.4 KB) Feel free to ask me any questions about the code or the program in general.

Remember, nearly all the code in galimber.h and galimber.cpp is derived directly from 50 year-old FORTRAN code, and doesn’t reflect the best coding practices of today. Nonetheless, it was a fun diversion to port it to the Makerphone with as few changes as possible.

In the original version of this app (1.0) posted above, attempting to quit after several minutes would require that mp be woken up with the power button and unlocked before mp.loader() would reload the firmware. I added a one-line fix to the code to prevent mp from going to sleep, which makes the quit work consistently regardless of how long you run the app. Here are zip files for the app directory (to copy to the SD card) and the source code files (to be put into an Arduino sketch named galimber) for version 1.0.1:

galimber_1.0.1.zip (668.2 KB)
galimber-src_1.0.1.zip (9.5 KB)

Also, a couple videos of galimber rotating CIGAR and SAMPLE objects:
galimber1.mp4
galimber2.mp4

Dear Frank,

This is to say the least, AMAZING! :smiley:

Love the work you’ve done here - it really shows how far the computers have come. Just the fact that you’re able to run this in real-time on such a tiny machine like this is amazing compared to the past.

Thank you for presenting this to us, along with the little story from your past. It is all extremely interesting!

You must’ve done some pretty amazing projects in the last 50 years then if this one was one of your firsts. :slight_smile:

Robert