com.partnersoft.geometry.xyz
Interface XyzShape<T extends XyzShape>

All Superinterfaces:
Immutable, java.lang.Iterable<XyzPoint>
All Known Implementing Classes:
XyzPoint, XyzPolyline

public interface XyzShape<T extends XyzShape>
extends Immutable, java.lang.Iterable<XyzPoint>

Generic supertype for all shapes in the (x, y, z) coordinate space.

Defines basic methods and enforces immutability and iterability. In addition, shapes must be defined in such a way that translation and uniform scaling do not change their class. Other types of affine transform may change the class. For example, scaling a cube by the same factor in all dimensions always results in a square. Translating it by moving it any amount in either dimension always results in a cube. However, scaling it by one factor in X and another factor in Y, or applying shears, results in something not a cube.

Subclasses should generally provide themselves as the generic type parameter T. For example:

 public class XyzPoint implements XyzShape<XyzPoint> {
 
This clever construction allows you to use e.g. scale() on a shape of declared type without having to cast the result:
 XyzPoint original = new XyzPoint(100, 100);
 XyzPoint scaled = original.scale(5);
 
Copyright 2007 Partner Software, Inc.

Version:
$Id: XyzShape.java 2328 2010-01-06 15:38:22Z paul $
Author:
Paul Reavis

Method Summary
 XyzBounds getBounds()
          Returns an XyzBounds object representing the rectangular extents of this shape.
 T scale(double factor)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 XyzShape transform(XyzTransform transform)
          Transform the shape using the given transform.
 T translate(double offsetX, double offsetY, double offsetZ)
          Translate the shape by adding all coordinates to the given x, y, and z offsets.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

scale

T scale(double factor)
Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions. This resulting shape must be of the same class as the original.

Parameters:
factor - scaling factor
Returns:
scaled result

translate

T translate(double offsetX,
            double offsetY,
            double offsetZ)
Translate the shape by adding all coordinates to the given x, y, and z offsets. The resulting shape must be of the same class as the original.

Parameters:
offsetX - offset for the x dimension
offsetY - offset for the y dimension
offsetZ - offset for the z dimension
Returns:
offset result

transform

XyzShape transform(XyzTransform transform)
Transform the shape using the given transform. Due to potential distortion the result may be a different type of shape than this one.

Parameters:
transform - affine transform to apply.
Returns:
transformed result

getBounds

XyzBounds getBounds()
Returns an XyzBounds object representing the rectangular extents of this shape.