Contents

Home Home
Physics Simulations and Artwork Physics
Simulations
Engineering Engineering
Fractals Fractals
Math Artwork Math Artwork
Rendered Artwork Rendered
Artwork
Hand-made Artwork Hand-made
Artwork
Bug Collection Bug
Collection
Programming Programming
High Voltage High
Voltage
Holography Holography
Physics Experiments Physics
Experiments
Legos Legos
Claymation Claymation
The Bible The Bible
Links Links
Computer Programming
These programs are just for fun. They may have some bugs so use them at your own risk. You are welcome to play with the source code to make your own fun programs.

C Programs
Note: In order to run some of these programs, you might need to place glut32.dll in your Windows folder (eg: “C:/Windows/glut32.dll” or “C:/WinNT/System32/glut32.dll”).
Click here to get free compilers from Microsoft. Includes Visual C++, Visual C#, Visual J#, Visual Basic, and ASP.

“Mario Space Ship” - C, OpenGL, 10/19/04
This is a fanciful level for the old Super Mario Bros. video game. The layout is based on one of my old drawings (1991).
Note: Super Mario Bros. is copyrighted by Nintendo. In the interest of not violating any copyright laws, I have decided not to make this game available to the public. Sorry!

“Torus Screensaver” - C++, OpenGL, 11/18/04
This is an animated torus knot screensaver. The screensaver part of the code was adapted from Eric Farmer’s OpenGL screensaver template. I have also included some Mathematica code and a rotatable 3D version of this surface.

“Asteroids.exe” - C, OpenGL, 10/12/04
Here is a game that incorporates gravity. This game uses my original old ship design for “Aroids”, a similar game that we made at Explorer Post 340, a robotics and logic lab that I used to attend back in 1994-1997. This game has bugs but I’m too lazy to fix it.

“Mandelbrot.exe” - C, OpenGL, 6/8/02
Here is a program to generate the Mandelbrot set fractal and a cubic Julia set fractal. This was my first OpenGL program. It is somewhat limited in what it can do, although the source code can easily be expanded.

“Space Maze” - C, OpenGL, 10/14/04
Help the Lego man through the maze. This maze is based on one of my old drawings (1989). Too difficult? Create your own maze! Simply replace “Maze.bmp” with your own 24 bit, 2n×2m pixel bitmap.

“Test.arx” - C++, ObjectARX 2000, 11/12/04
Here is my first AutoCAD Runtime Extension (ARX) program with source code. ARX is a C++ library for customizing AutoCAD.

3D Graphics - Mathematica 4.2, 5/25/06
Here is some fun Mathematica code that demonstrates 3D graphics. Phong shading is used to interpolate the surface normals across each polygon. The simplest method is the Painter’s Algorithm which draws all the polygons in the order they overlap. However, this does not account for intersecting polygons. An improved method, called Z-buffering keeps track of the depth. This method is used by OpenGL and it is usually fast enough for real-time graphics. See also my Mathematica code for a very simple ray tracer.
(* runtime: 18 seconds *)
n = 26; f := 0.125Cos[4Pi Sqrt[x^2 + y^2]]; Clear[x, y]; grad = {-D[f, x], -D[f, y], 1};
Normalize[x_] := x/Sqrt[x.x]; phi = -Pi/4; R = {{1, 0, 0}, {0, Cos[phi], Sin[phi]}, {0, -Sin[phi], Cos[phi]}};
nodes = Flatten[Table[R.{x, y, f}, {y, -1, 1, 2/(n - 1)}, {x, -1, 1, 2/(n - 1)}], 1];
normals = Flatten[Table[R.Normalize[grad], {y, -1, 1, 2/(n - 1)}, {x, -1, 1, 2/(n - 1)}], 1];
colors = Flatten[Table[(1 - 8 f)/3, {y, -1, 1, 2/(n - 1)}, {x, -1, 1, 2/(n - 1)}], 1];
elements = Flatten[Table[{{i, i + 1, i + n}, {i + 1, i + n + 1, i + n}} + (j - 1) n, {j, 1, n - 1}, {i, 1,n - 1}], 2];
n = 275; xmin = ymin = -1; xmax = ymax = 1; image = Table[Hue[0, 0, 0], {n}, {n}]; zbuffer = Table[-1, {n}, {n}];
xIntersect[{{x1_, y1_, z1_}, {x2_, y2_, z2_}}] := If[y1 ==y2, Infinity, x1 + (y - y1)(x2 - x1)/(y2 - y1)];
Colorize[hue_, x_] := Hue[hue, Min[1, Max[0, 2(1 - x)]], Min[1, Max[0, 2x]]];
Scan[(plist = {p1, p2, p3} = {{x1, y1,z1}, {x2, y2, z2}, {x3, y3, z3}} = nodes[[#]]; d = Det[{{x2 - x1, y2 - y1}, {x3 - x1, y3 - y1}}]; If[d != 0, {n1, n2, n3} = normals[[#]]; {c1, c2, c3} = colors[[#]]; ilist = (n - 1)(plist[[All, 2]] - ymin)/(ymax - ymin) + 1; n0 = Normalize[Cross[p2 - p1, p3 - p1]]; Do[y = ymin + (ymax - ymin)(i - 1)/(n - 1); {xa, xb, xc} = Map[xIntersect, Partition[Sort[plist, #1[[2]] < #2[[2]] &], 2, 1,1]]; jlist = (n - 1)({xc, If[Abs[xb - xc] < Abs[xa - xc],xb, xa]} - xmin)/(xmax - xmin) + 1; Do[x = xmin + (xmax - xmin)(j - 1)/(n - 1); xi = Det[{{x - x1, y - y1}, {x3 - x1, y3 - y1}}]/d; eta = Det[{{x2 - x1, y2 - y1}, {x - x1, y - y1}}]/d; z = z1 + (z2 - z1)xi + (z3 - z1)eta; If[z > zbuffer[[i, j]], zbuffer[[i, j]] = z; lightdir = Normalize[{0, 0, 1} - {x, y, z}]; normal = n1 + (n2 -n1) xi + (n3 - n1) eta; reflect = Normalize[2(normal.lightdir) normal - lightdir]; specular =reflect.lightdir; image[[i, j]] =Colorize[c1 + (c2 - c1) xi + (c3 - c1)eta, 0.4Max[0, normal.lightdir] + 0.6specular^10]], {j, Max[1, Ceiling[Min[jlist]]], Min[n, Floor[Max[jlist]]]}], {i, Max[1, Ceiling[Min[ilist]]], Min[n, Floor[Max[ilist]]]}]]) &, elements];
ListDensityPlot[zbuffer, Mesh -> False, Frame -> False]
Show[Graphics[RasterArray[image], AspectRatio -> 1]]

Graphics Links
NeHe - great OpenGL tutorials (particles, mirrors, etc.) and OpenGL contest (my favorite is “Water Garden”)
Paul Bourke - tons of graphics information
Sulaco - impressive Delphi programs by Jan Horn, see Dynamic Cube Mapping, SAGameDev Demo, Peristalsis, Plasma Tunnel
Paul Baker - OpenGL C programs, see Cloth Simulation, Shadow Volumes, Quake 3 BSP, Bump Mapping, Render To Texture
Hugo Elias - graphics information and physics simulations
Bitmap Tutorial - how to make bitmaps, by Andreas Hartl

Java Applets
“Mandelbrot” - 6/9/01, Applet along with source code to generate Mandelbrot and Julia Set fractals. This is the only Java applet on my web site at this time.
Java Links
Ken Perlin - educational computer graphics, many Java applets: Face Demo, Car, etc.
Rubik’s Cube Java Applets - 3x3, 4x4, and 5x5
Arcade Emulators: Borne d'arcade, JEmu
particle simulator - fun Java applet by Chris Laurel
Voxel - 3D Flight Simulator Java applet
Connect 4 - Java applet

AutoLisp Programs
Lisp (List Programming) is an interpreted language, although it can be compiled to run faster. It is also a popular language for artificial intelligence programming. I also think it’s good for programming symbolic calculators (like Mathematica). The following programs were written in AutoLisp. To run these programs, you will need access to AutoCAD:
“Tessellations.lsp” - 12/9/02, a fun program to help you create your own tessellations
“Signature.vlx” - 12/20/03, a compiled Autolisp program to display the automation program signature in AutoCAD
“Functions.lsp” - Here are some useful functions for finding intersection points and areas of polylines, and for testing to see if a point is inside a polyline. You can find whether a point is inside any arbitrary shape by counting the intersections from a ray outside the shape. This technique can also be extended to 3D objects, as in ray tracing.
“Lisptohtml.lsp” - 9/9/04, program to convert Autolisp files to html in Visual Lisp format
Links
AfraLisp - great AutoLisp tutorials
Cadalyst AutoLisp Code
PLT Scheme - free, similar to Lisp

Flash
Flash Animation - 6/30/03, my first attempt at a Flash animation
Flash Link: Goober Productions - a good example of Flash animation


Other Programming Links
RoboCup - project to build robots that can beat human professional soccer players by the year 2050, see this video
Artificial Linguistic Internet Computer Entity (ALICE) - awarded “most-human” chatbot, decide for yourself, see also Turing Test
Breaking a Visual CAPTCHA - an algorithm that can break CAPTCHA tests (Completely Automated Public Turing Test to tell Computers and Humans Apart)
Play 20 Questions with Darth Vador - funny algorithm