Java 2 includes an affine transformation class, to use for 2D graphics and animation. However, many (perhaps most) browsers in the field don't have built-in support for Java 2 or the affine transform. This Java applet implements an affine transform using only Java 1.0 classes and methods, so it can be viewed by almost any browser, regardless of vintage.
Homogeneous coordinates are used, with the third coordinate always set to h = 1. This allows use of a composite transformation matrix which concatenates all needed translations, rotations, and scaling into a single matrix which is then applied to each polygon to be rendered. The result is code that is compact and easy to maintain, with excellent performance at frame rates as high as 10 per second.
Click the link below to see the complete source file. I first built and tested this applet with Apple's MRJ SDK 2.2, but it should build and run with any version of Java on any platform. Please let me know if you find a version or platform that doesn't work. The source code is offered free for all uses, so it's up to you to determine if it is suitable for your application.CrankShaft.java Source File.