Java Geometry, Cartography, and GPS Demos

Search Algorithms

This is another demo from the GPS class. You can build a network in the left-hand pane by clicking to create nodes and dragging between them to create links. Start and goal nodes are created automatically but can be reselected by choosing the appropriate button at the top. As you build the network, its tree representation is created in the right-hand pane with respect to your chosen start and goal nodes. You can choose among 4 search strategies—depth first, breadth-first, branch and bound, and A*. Please see the accompanying documentation on this link for more detailed instructions.

Hyperbolic Coordinates for Navigation

In my GPS class (GOG 479/579) we discuss earlier forms of electronic navigation, including LORAN, which used hyperbolic coordinates to determine position. This applet demos how the position of an object can be found with respect to two intersecting hyperbolas. The applet plots hyperbolas with respect to 3 reference towers (labeled with typical LORAN tower designations) and the position of a receiver (the boat). Yes—I know boats don’t usually drive over land!

Douglas Line Simplification

I use this applet to demo recursive programming, mouse event handling, and the Douglas line simplification algorithm (D.H. Douglas and T.K. Peucker, “Algorithms for the reduction of the number of points-required to represent a line or its caricature,” The Canadian Cartographer, 10, (2), 112–122(1973)). As you click on the canvas, vertices and connecting line segments are drawn. By increasing the tolerance from 0 (in pixels), simplified versions of the line appear in red, overlain on the original. Vertices can be dragged with the mouse.

Practice with Scale Conversion

This is one of the first Java applets I ever wrote. I used it to help my Introduction to Cartography (GOG 290) students practice converting map scales. It still works for the most part although the context sensitive help has mysteriously disappeared…

Circumference Calculator

This is a very simple applet that I use to introduce my students to some basic computational techniques and to the construction of an event driven user interface. Enter a latitude in degrees to get the circumference along a parallel at that latitude. The calculations assume a spherical earth with a radius equivalent to the Clarke 1866 ellipsoid equatorial radius. This is one of the first projects that students implement in GOG 414/590, Computer Mapping/Advanced Cartography

Affine Transformation

This is another simple applet that demos 2D translation, rotation, and scaling through coordinate system transformation. A rectangle is drawn at the coordinate system origin. The user translates the origin by clicking on a new location. The X and Y axes can be scaled separately by changing their values in the appropriate text boxes. The coordinate system axes can be similarly rotated with respect to the page by changing the text value. The coordinate axes and the rectangle are redrawn whenever the user selects a new point or changes the scaling and rotation parameters. I kept the interface as simple as possible to keep the code accessible to beginning students.

3D Transformations and Shading

I use this applet in the second of my 2 Java programming classes to demonstrate the use of plane equations in support of 3D affine transformations and surface shading applications. Although it’s best to use the Java 3D API (a Java wrapper for OpenGL) for a demo of this sort, most users’ browsing environments will not have the appropriate client-side libraries to make this work. Therefore I have implemented 3D transformations, including 3D perspective transformations, using the javax.vecmath package’s vector and matrix resources. This provides a pretty good simulation of a true ‘3D’ application for smaller demo programs.

Point in Polygon Test by Ray Intersection

Almost any program running within an event-driven graphical user interface must determine where mouse clicks occur. This is especially true in GIS applications where a click on a map may select a shape for some operation. A standard point-in-polygon test is performed by running a ray from the test point to the exterior of the target polygon. If the ray intersects the polygon an even number of times, the point is inside. Otherwise, it’s outside. This program uses simple line segment intersection tests to count intersections and to restrict the user from creating self-intersecting polygons.