public abstract class Polytope
implements Shape, java.io.Serializable
Representation of a mathematical polytope, which is a finite region of space
enclosed by a finite number of hyperplanes. Subclasses include LineSegment (a
1-D polytope), Polygon (a 2-D polytope), and Polyhedron (a 3-D polytope).
Note that the polytope may be embedded in a space of higher dimension than
its geometric dimension (e.g., a square -- a 2-D polytope -- by be used in a
three-dimensional space. A primary feature of these classes is the set of
points representing the vertices of the polytope. These points have the
dimension of the embedded space. Subclasses usually have their own internal
representation of the polytope that is used to calculate the vertices. It
restricts access to this representation to restrict the shape of the polytope
(e.g., a square polytope can be modified only by setting the common length of
its sides). A polytope can be positioned to any point in space and (to be
developed) given a rigid-body rotation.
Constructs a polytope of dimension D from the D-1 finite "planes" that
constitute it. Constructor does not find the vertices by calculating
plane intersections; instead the given planes should be configured with
vertices that form the polytope.
public abstract void updateVertices()
This method should be defined by the subclass to calculate the vertices
in accordance with the internal representation of the polytope. If the
internal representation is kept by the vertices themselves, then this
method need do nothing; if this method applies another internal
representation to the vertices (for example, it might represent a square
by keeping the edge length), it should then invoke
applyTranslationRotation() before returning. Subclass methods allowing
mutation of the internal representation should invoke updateVertices to
ensure the vertices reflect the internal state. Vertices may be
changed directly, but these changes will overridden by updateVertices if
it is called afterwards.
protected void applyTranslationRotation()
Calculate transformed vertices from current values of vertices, position,
and orientation. Does not invoke updateVertices before transforming, and
so should be called only by subclass and only at the end of the updateVertices
method. Otherwise translation and rotation will be performed from current
value of vertices, compounding previous application of
translation/rotation. NOTE: Rotation is not yet implemented.
Returns an array of all vertices of the polytrope. For most subclasses
this array will not provide the direct representation of the polytope.
Instead polytope will be defined in another internal representation, which is
used to calculate the vertices via the updateVertices method. In a few
subclasses the vertices are the representation, so alteration of the
returned array will change the polytope.
Returns the geometric center of the polytope. The returned vector is used
to define the position internally, so changes to it will affect the
logical position of the polytope, without immediately changing the vertices.
Use setPosition to change the polytope position.
public abstract double getVolume()
Returns the (hyper)volume enclosed by the polytope. So
for a LineSegment instance, this is its length; for a
polygon, it is the area; for a polyhedron, it is the volume.