com.partnersoft.geometry.xyz
Class XyzPolyline

java.lang.Object
  extended by com.partnersoft.geometry.xyz.XyzPolyline
All Implemented Interfaces:
Immutable, XyzShape<XyzPolyline>, java.lang.Iterable<XyzPoint>

public class XyzPolyline
extends java.lang.Object
implements XyzShape<XyzPolyline>

A polyline consisting of at least two vertices and one line segment.

Copyright 2007 Partner Software, Inc.

Version:
$Id: XyzPolyline.java 1012 2007-11-24 18:30:02Z paul $
Author:
Paul Reavis

Constructor Summary
XyzPolyline(double... coords)
           
XyzPolyline(double[] coordsX, double[] coordsY, double[] coordsZ)
           
XyzPolyline(java.util.List<XyzPoint> points)
           
XyzPolyline(XyzPoint... points)
           
 
Method Summary
 boolean contains(XyzPoint point)
           
 XyzBounds getBounds()
          Returns an XyzBounds object representing the rectangular extents of this shape.
 java.util.Iterator<XyzPoint> iterator()
           
 XyzPolyline scale(double factor)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 XyzPolyline scale(double factorX, double factorY, double factorZ)
           
 XyzPolyline simplify(double granularity)
          Simplify the polyline by eliminating segments whose length is less than the given granularity.
 XyzPolyline simplify2(double granularity)
           
 XyzPolyline transform(XyzTransform transform)
          Transform the shape using the given transform.
 XyzPolyline 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XyzPolyline

public XyzPolyline(double... coords)

XyzPolyline

public XyzPolyline(double[] coordsX,
                   double[] coordsY,
                   double[] coordsZ)

XyzPolyline

public XyzPolyline(XyzPoint... points)

XyzPolyline

public XyzPolyline(java.util.List<XyzPoint> points)
Method Detail

simplify

public XyzPolyline simplify(double granularity)
Simplify the polyline by eliminating segments whose length is less than the given granularity. Returns null if the polyline degenerates into a single point.

More accurately, what this method does is define a grid with square cells the size of the granularity. It then iterates through the polyline and eliminates points falling into the same cell as the previous point. This provides similar results to the elimination of short segments but much more efficiently. There will be edge effects, however (e.g. where point[i] is just barely to one side of a grid line and point[i + 1] is just barely to the other).

Parameters:
granularity - size of the discreteness grid applied to eliminate points that are too close

simplify2

public XyzPolyline simplify2(double granularity)

scale

public XyzPolyline scale(double factorX,
                         double factorY,
                         double factorZ)

scale

public XyzPolyline scale(double factor)
Description copied from interface: XyzShape
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.

Specified by:
scale in interface XyzShape<XyzPolyline>
Parameters:
factor - scaling factor
Returns:
scaled result

translate

public XyzPolyline translate(double offsetX,
                             double offsetY,
                             double offsetZ)
Description copied from interface: XyzShape
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.

Specified by:
translate in interface XyzShape<XyzPolyline>
Parameters:
offsetX - offset for the x dimension
offsetY - offset for the y dimension
offsetZ - offset for the z dimension
Returns:
offset result

transform

public XyzPolyline transform(XyzTransform transform)
Description copied from interface: XyzShape
Transform the shape using the given transform. Due to potential distortion the result may be a different type of shape than this one.

Specified by:
transform in interface XyzShape<XyzPolyline>
Parameters:
transform - affine transform to apply.
Returns:
transformed result

getBounds

public XyzBounds getBounds()
Description copied from interface: XyzShape
Returns an XyzBounds object representing the rectangular extents of this shape.

Specified by:
getBounds in interface XyzShape<XyzPolyline>

contains

public boolean contains(XyzPoint point)

iterator

public java.util.Iterator<XyzPoint> iterator()
Specified by:
iterator in interface java.lang.Iterable<XyzPoint>