Geometry Applet Programming Reference
version 2.2
The Geometry Applet was provided to Science Buddies by kind permission of its author, Professor David Joyce. The applet was written to illustrate Euclid's Elements. In the applet you see an icosahedron, that is, a regular 20-sided solid, constructed according to Euclid's construction in proposition Clark U XIII.16.
Another example using this Geometry Applet illustrates the Euler line of a triangle.
Here's how you can manipulate the figure that appears size="40". If you click on a point in the figure, you can usually move it in some way. A free point *, usually colored red, can be freely dragged about, and as they move, the rest of the diagram (except the other free points) will adjust appropriately. A sliding point *, usually colored orange, can be dragged about like the free points, except their motion is limited to a straight line, a circle, a plane, or a sphere, depending on the point. Other points can be dragged to translate the entire diagram. If a pivot point * appears, usually colored green, then the diagram will be rotated and scaled around that pivot point.
Try dragging around some of the points in the diagram size="40".
Also, if you type r or the space key while the cursor is over the diagram, then the diagram will be reset to its original configuration. If you type u or return the figure will be lifted off the page into a separate window. Typing d or return while the cursor is over the original window will return the diagram to the page. Note that you can resize the floating window to make the diagram larger.
Parameters
Parameters are specified in the following format:
<param name=yyyy value="zzzz">
where the name, yyyy, may be one of the following:
- background - the background color (for specifying the value, see below);
- font - the font for displaying letters in the figure (default TimesRoman);
- fontsize - the size of the font for displaying letters (default 18);
- align - the alignment method for positioning letters (for specifying the value, see below);
- title - the title of the figure, used for a floating frame;
- debug - the debugging switch, by default, off;
- pivot - the name of a pivot point, if any;
- e[i] - an element. The elements are numbered from 1 on up (for specifying the value, see below).
Elements
The format for an element is a little complicated. Here is the minimal specification for an element:
<param name=e[1] value="A;point;free;50,50">Each element has a number, which appears in the square brackets, "[ ]". The number for this element is 1, which means that it is the first element to be created. The "value" for each element consists of up to 8 arguments, separated by semicolons. The first four arguments are required:
- a name,
- an element class,
- a construction method, and
- construction data.
For the example element size="40", its name is "A". Its class is point. Its construction method is free, which means it can be freely dragged about. Its construction data is "50,50", which means that it will be initially placed at pixel coordinates (50,50). (Note that the parameters of the construction data are separated by commas, and that the semicolon following the final argument may be omitted.) The coordinate system follows the conventions of screen coordinates: the origin of the coordinate system is the top left corner of the diagram; the positive x-axis is to the right; the positive y-axis is down.
Colors
The four optional arguments (#'s 5–8) are used to specify colors for attributes of an element. If these arguments are omitted, then default colors are used. The optional arguments are (continuing the previous list):
- the color of the name of the element;
- the color of the 0-dimensional parts (points) of the element;
- the color of the 1-dimensional parts (lines or arcs) of the element; and
- the color of the 2-dimensional parts of the element (if any).
Colors can be declared in a three different ways.
- A single word specifying the color may be given. These possible colors are * black, * blue, * cyan, * darkGray, * gray, * green, * lightGray, * magenta, * orange, * pink, * red, * white, and * yellow. If the word "random" is specified, then a randomly chosen pastel will be used. If an element is specified as "background", then it will be given the background color; if "brighter", then a brighter version of the background; if "darker", then a darker version of the background; and if "none" then it won't appear.
- Specific colors may be given by their red, green, and blue components as six hexadecimal digits in an rrggbb format (i.e., the first pair of digits specifies the red component, the second pair of digits specifies the green component, and the third pair of digits specifies the blue component of the color). A value of "0"
- A color can be given as a triple of decimal numbers separated by commas to indicate hue (0 to 360), saturation (0 to 100), and brightness (0 to 100).
Here is an example of an element with all eight arguments:
<param name=e[7] value="semiAC;sector;sector;ACm,A,C;0;0;blue;200,3,95"> For this example element, its name is "semiBA". Its class is sector. Its construction method is also sector. Its construction data is "ACm,A,C" (three previously-defined points). Its name will not appear on the diagram, nor will its points, because the next two arguments are both 0. Its outline will appear in blue. Finally, it will be filled with a light blue color, specified by the triple "200,3,95" (for hue, saturation, and brightness).
Alignment
Currently, there are five values for alignment: size="40", RIGHT, BELOW, LEFT, and CENTRAL (the default). For size="40" alignment, the names of points appearing in the diagram will appear size="40" points. Analogously for RIGHT, BELOW, and LEFT. For CENTRAL alignment, letters will appear away from the center of the diagram.Element classes and construction methods
There are eight different element classes: point, line, circle, polygon, sector, plane, sphere, and polyhedron. Only the first five classes are used in plane geometry. All can be used in solid geometry.Each class has several construction methods. The eight tables below briefly explain these construction methods.
Special notes
1. Any time two points are needed in a construction, one line may be given instead. For instance, if AB has already been defined as a line that connects points A and B, then the triangle ABC can be defined by either of these:value="ABC;polygon;triangle;A,B,C"
value="ABC;polygon;triangle;AB,C"
2. Those constructions that can only be used in solid geometry are indicated with a light green background color. |
3. Optional data elements are indicated in the tables by square brackets. In particular, [z] indicates z is an optional integer, and [plane A] indicates A is an optional plane. The optional data elements are only used in solid geometry; they should always be omitted in plane geometry.
- 3a. When an optional third coordinate [z] is not specified, it is taken to be 0 so that the point lies in the xy-plane, that is, the plane of the screen.
- 3b. When an optional plane such as [plane A] is not specified, it is assumed to be the xy-plane.
4. Data parameters come in three kinds: (1) integers, (2) points, and (3) other elements. These are indicated in separate lines in the tables. As long as the parameters of each kind come in the right order, they will be interpreted properly. Parameters of different kinds may be listed as you like.
Index of tables
- Table 1: Element class point
- Constructions: free, midpoint, intersection, first, last, center, lineSlider, circleSlider, circumcenter, vertex, foot, cutoff, extend, parallelogram, similar, perpendicular, proportion, invert, meanProportional, planeSlider, sphereSlider, angleBisector, angleDivider, fixed, lineSegmentSlider
- Table 2: Element class line
- Constructions: connect, angleBisector, angleDivider, foot, chord, bichord, perpendicular, cutoff, extend, parallel, similar, proportion, meanProportional
- Table 3: Element class circle
- Constructions: radius, circumcircle, invert, intersection
- Table 4: Element class polygon
- Constructions: square, triangle, quadrilateral, pentagon, hexagon, equilateralTriangle, parallelogram, regularPolygon, starPolygon, similar, application, octagon, face
- Table 5: Element class sector
- Constructions: sector, arc
- Table 6: Element class plane
- Constructions: 3points, perpendicular, parallel, ambient
- Table 7: Element class sphere
- Construction: radius
- Table 8: Element class polyhedron
- Constructions: tetrahedron, parallelepiped, prism, pyramid
Element class point
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
free | integers x, y | a freely dragable point in the screen plane with initial coordinates (x,y,0) |
midpoint | points A, B | the midpoint of a line AB |
intersection | points A, B, C, D [plane E] |
the intersection of two lines AB and CD in the plane E |
points B, C plane A |
the intersection of the plane A and the line BC | |
first | points A, B | the first end A of the line AB |
last | points A, B | the last end B of the line AB |
center | circle A | the center of the circle A |
sphere A | the center of the sphere A | |
lineSlider | points A, B integers x, y,[z] |
a point that slides along a line AB with initial coordinates (x,y,z) |
circleSlider | circle A integers x, y,[z] |
a point that slides along a circle A with given initial coordinates (x,y,z) |
circumcenter | points A, B, C [plane D] |
the center of a circle ABC passing through 3 points A, B, and C in the plane D |
vertex | polygon A integer i |
a vertex A_{i} of the polygon A_{1}A_{2}...A_{n} with index i |
foot | points A, B, C | the foot of a perpendicular drawn from A to a line BC |
point A plane B |
the foot of a perpendicular drawn from A to a plane B | |
cutoff | points A, B, C, D | the point E on a line AB so that AE = CD |
extend | points A, B, C, D | the point E on a line AB so that BE = CD |
parallelogram | points A, B, C | the 4th vertex D of a parallelogram ABCD given 3 vertices A, B, and C |
similar | points A, B, D, E, F [planes C, G] |
the point H so that triangle ABH in plane C is similar to triangle DEF in plane G |
perpendicular | points A, B, [plane C] |
the point D so that AD is equal and perpendicular to AB in plane C |
points A, B, D, E [plane C] |
the point F so that AF is perpendicular to AB in plane C and equals DE | |
points A, C, D plane B |
the point E on the line perpendicular to plane B passing through A so that the distance from E to B equals CD | |
proportion | 8 points A, B, C, D, E, F, G, H | the point I on GH so that AB:CD = EF:GI |
invert | point A circle B |
the image of a point A inverted in the circle B |
meanProportional | 6 points A, B, C, D, E, F | the point G on EF so that AB:CD = CD:EG |
planeSlider | plane A integers x, y, z |
a point that slides on the plane A with initial coordinates (x,y,z) |
sphereSlider | sphere A integers x, y, z |
a point that slides on the sphere A with initial coordinates (x,y,z) |
angleBisector | points A, B, C [plane D] |
The point at the intersection of the angle bisector of angle BAC and the line BC in plane D |
angleDivider | points A, B, C [plane D] integer n |
The point E on the line BC so that angle BAE is the n^{th} part of the angle BAC in plane D |
fixed | integers x, y,[z] | the fixed point with coordinates (x, y, z) |
lineSegmentSlider | points A, B integers x, y,[z] |
a point that slides along within the line segment AB with initial coordinates (x,y,z) |
harmonic | points B, C, D | the harmonic conjugate of B with respect to C and D |
Element class line
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
connect | points A, B | the line AB connecting two points A and B |
angleBisector | points A, B, C [plane D] |
the line AE bisecting angle BAC with E on BC in plane D |
angleDivider | points A, B, C [plane D] integer n |
the line AE with E on BC so that BAE is the n^{th} part of the angle BAC in plane D |
foot | 3 points A, B, C | the line AD drawn perpendicular to BC in the screen plane |
point A plane B |
the line AD drawn perpendicular to plane B with the point D lying on B | |
chord | points A, B circle C |
the intersection of the line AB in the circle C |
bichord | circles A, B | the common chord connecting the two intersection points of the circles A and B |
perpendicular | points A, B [plane C] |
the line AD equal and perpendicular to AB in plane C |
points A, B, D, E [plane C] |
the line AF perpendicular to AB in plane C equal to DE | |
point A, C, D plane B |
the line EF perpendicular to plane B passing through A equal to CD with E lying on B | |
cutoff | points A, B, C, D | the line AE equal to CD along the line AB |
extend | points A, B, C, D | the line BE equal to CD so that A, B, and C are collinear with B between A and C |
parallel | points A, B, C | the line AD parallel and equal to BC |
similar | points A, B, D, E, F [planes C, G] |
the line AH so that triangle ABH in plane C is similar to triangle DEF in plane G |
proportion | 8 points A, B, C, D, E, F, G, H | the line GI along GH so that AB:CD = EF:GI |
meanProportional | 6 points A, B, C, D, E, F | the line EG along EF so that AB:CD = CD:EG |
Element class circle
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
radius | points A, B [plane C] |
the circle with center A and radius AB in the plane C |
points A, B, C [plane D] |
the circle with center A and radius BC in the plane D | |
circumcircle | points A, B, C [plane D] |
the circle passing through 3 points A, B, and C in the plane D |
invert | circles A, B | the image of circle A inverted in circle B |
intersection | spheres A, B | the intersection of spheres A and B |
Element class polygon
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
square | points A, B [plane C] |
the square on a side AB in plane C |
triangle | points A, B, C | the triangle ABC given 3 vertices A, B, and C |
quadrilateral | points A, B, C, D | the quadrilateral ABCD given 4 vertices A, B, C, and D |
pentagon | points A, B, C, D, E | the pentagon given 5 vertices |
hexagon | points A, B, C, D, E, F | the hexagon given 6 vertices |
equilateralTriangle | points A, B [plane C] |
the equilateral triangle on a side AB in plane C |
parallelogram | points A, B, C | the parallelogram ABCD given A, B, and C |
regularPolygon | points A, B integer n |
the regular polygon on a side AB given the number of vertices n |
starPolygon | points A, B integers n, d |
the star polygon on a side AB given the number of vertices n and the density d |
similar | points A, B, D, E, F [planes C, G] |
the triangle ABH in plane C is similar to triangle DEF in plane G |
application | polygon A points B, C, D |
the parallelogram equal to the given polygon A with one side BC and one angle BCD |
octagon | 8 points A, B, C, D, E, F, G, H | the octagon given 8 vertices |
face | polyhedron A integer n |
the n^{th} face of polyhedron A |
Element class sector
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
sector | points A, B, C [plane D] |
the sector of a circle in plane D given the center A and two points B and C on the circumference |
arc | points A, B, C [plane D] |
the sector of a circle in plane D whose arc passes through the three points A, B and C |
Element class plane
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
3points | points A, B, C | the plane passing through points A, B, and C |
perpendicular | points A, B | the plane passing through point A and perpendicular to line AB |
parallel | plane A point B |
the plane passing through point A and parallel to plane B |
ambient | point A | the ambient plane of point A |
circle A | the ambient plane of circle A |
Element class sphere
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
radius | points A, B | the sphere with center A and radius AB |
points A, B, C | the sphere with center A and radius BC |
Element class polyhedron
(argument #2)
Construction method (argument #3) |
Construction data (argument #4) |
Description |
---|---|---|
tetrahedron | points A, B, C, D | the tetrahedron given four vertices |
parallelepiped | points A, B, C, D | the parallelepiped with three edges AB, AC, and AD |
prism | polygon A points B, C |
the prism with base A and side edges parallel and equal to BC |
pyramid | polygon A point B |
the pyramid with base A and apex B |
Source files
The Geometry Applet uses a Slate Canvas put all the Elements on. The slate can be lifted off into a separate window, and that uses ClientFrame, a subclass of Frame. An Element is a generic thing which is subclassed in eight different ways to give actual elements that can be displayed. These eight classes are further subclassed, too.- PointElement with subclasses AngleDivider, CircleSlider, FixedPoint, Foot, Harmonic, Intersection, IntersectionPL, InvertPoint, Layoff, LineSlider, MeanProportional, Midpoint, PlaneFoot, PlaneSlider, Proportion, Similar, and SphereSlider.
- LineElement with subclasses Bichord, Chord, Perpendicular, and PlanePerpendicular.
- CircleElement with subclasses Circumcircle, IntersectionSS, amd InvertCircle.
- PolygonElement with subclasses Application, and RegularPolycon.
- SectorElement with subclass Arc.
- PlaneElement with subclasses ParallelP and PerpendicularPL.
- SphereElement.
- PolyhedronElement with subclasses Prism and Pyramid.
The source files *.java are zipped in the file http://www.cdn.sciencebuddies.org/Dirs/4/13/CompSci_GeometryAppletSource.zip. The class files *.class are zipped, but uncompressed, in the file http://www.cdn.sciencebuddies.org/Dirs/4/13/Math_GeometryApplet.zip.