1.1 Data Classes

Following is an overview of the high-level Java objects used in Tangram.

TangramPuzzle

This is the basic container for puzzles. It includes their name, source, list of TangramPieces, and methods for reading, building, and validating puzzles.

TangramPiece

An abstract class representing a single tan. It defines its shape, rotation, position, and in the case of the parallelogram whether it is flipped over. It includes a few helper methods for checking whether the edges of two tans are touching. There are subclasses of this for each type of tan.

TPoint

An \(x, y\) coordinate in \(Q\sqrt{2}\) space, which is known as the Real Quadratic Field. Coordinates are defined as \(a_{x}+b_{x}\sqrt{2}\), \(a_{y}+b_{y}\sqrt{2}\). Since most puzzles have tans oriented at multiples of 45°, using separate coefficients for the rational part and a multiple of \(\sqrt{2}\) allows them to be integers in the vast majority of cases. This is an abstract class, with separate ImmutableTPoint and MutableTPoint implementations that are alternately used depending on whether ease of math operations or reducing Java object allocations is needed more.

TEdge

A line segment in \(Q\sqrt{2}\) space. This utility class is used to help snap tans together, test for overlaps, and is a component of TPolygons.

TPolygon

A polygon in \(Q\sqrt{2}\) space. This is used to find the silhouette of a puzzle and compare two puzzles to see whether they are identical (i.e. make the same shape).


JavaScript license information