com.partnersoft.geometry.xyz
Class XyzPoint

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

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

A 3-dimensional point in x, y, z space.

Copyright 2006-2007

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

Constructor Summary
XyzPoint(double x, double y, double z)
           
 
Method Summary
 double distanceFrom(XyzPoint nother)
          Returns the straight-line distance between this point and the one given.
 double distanceSquaredFrom(XyzPoint nother)
          Returns the square of the straight-line distance between this point and the one given.
 boolean equals(java.lang.Object nother)
           
 XyzBounds getBounds()
          Returns an XyzBounds object representing the rectangular extents of this shape.
 double getX()
          X coordinate.
 double getY()
          Y coordinate.
 double getZ()
          Z coordinate.
 java.util.Iterator<XyzPoint> iterator()
           
 XyzPoint offsetFrom(XyzPoint nother)
          Returns the offset, or three-dimensional difference, between this point and the other.
 XyzPoint scale(double scale)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 XyzPoint scale(double scaleX, double scaleY, double scaleZ)
           
 java.lang.String toString()
           
 XyzShape transform(XyzTransform transform)
          Transform the shape using the given transform.
 XyzPoint 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, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XyzPoint

public XyzPoint(double x,
                double y,
                double z)
Method Detail

distanceFrom

public double distanceFrom(XyzPoint nother)
Returns the straight-line distance between this point and the one given.

Parameters:
nother - other point to measure from
Returns:
distance from other point

distanceSquaredFrom

public double distanceSquaredFrom(XyzPoint nother)
Returns the square of the straight-line distance between this point and the one given. Since it avoids the square root operation required by the regular distance function, it's more efficient if you are doing a lot of distance comparisons.

Parameters:
nother - other point to measure from
Returns:
square of the distance from other point

offsetFrom

public XyzPoint offsetFrom(XyzPoint nother)
Returns the offset, or three-dimensional difference, between this point and the other. Subtracks the given point's x, y, and z coordinates from this one's and returns the result.

Parameters:
nother - point to calculate offset from
Returns:
x, y, z difference from offset point

scale

public XyzPoint scale(double scaleX,
                      double scaleY,
                      double scaleZ)

scale

public XyzPoint scale(double scale)
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<XyzPoint>
Parameters:
scale - scaling factor
Returns:
scaled result

translate

public XyzPoint 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<XyzPoint>
Parameters:
offsetX - offset for the x dimension
offsetY - offset for the y dimension
offsetZ - offset for the z dimension
Returns:
offset result

transform

public XyzShape 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<XyzPoint>
Parameters:
transform - affine transform to apply.
Returns:
transformed result

iterator

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object nother)
Overrides:
equals in class java.lang.Object

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<XyzPoint>

getX

public double getX()
X coordinate.

Returns:
x coordinate value

getY

public double getY()
Y coordinate.

Returns:
y coordinate value

getZ

public double getZ()
Z coordinate.

Returns:
z coordinate value