com.hedgehog.geo.threed.points
Class Point3DWithAdjacentPoints

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.geo.GeometricObject
          extended by com.hedgehog.geo.threed.GeometricObject3D
              extended by com.hedgehog.geo.threed.points.Point3D
                  extended by com.hedgehog.geo.threed.points.Point3DWithAdjacentPoints
All Implemented Interfaces:
DimensionPoint<HDouble>, ModelObject, java.lang.Comparable, java.util.Comparator

public class Point3DWithAdjacentPoints
extends Point3D
implements ModelObject

Title: Point3DWithAdjacentPoints - extends Point3D by appending point adjacency information.

Description: Extends Point3D by appending a vector of adjacent points to a point.

Useful for modelling systems such as mass-spring point nets in which it is required for points to know their immediate neighbours.

Copyright: Copyright (c) Hedgehog Software 2007-2009.

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
protected  java.util.Vector<Point3D> mAdjacentPoints
          Vector of adjacent points.
 
Fields inherited from class com.hedgehog.geo.threed.points.Point3D
mx, my, mz
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
Point3DWithAdjacentPoints()
          Default constructor.
Point3DWithAdjacentPoints(double x, double y, double z)
          Constructor.
Point3DWithAdjacentPoints(double x, double y, double z, java.util.Vector<Point3D> adjacentPoints)
          Constructor.
Point3DWithAdjacentPoints(Point3DWithAdjacentPoints object)
          Copy constructor.
 
Method Summary
 boolean addAdjacentPoint(Point3D adjacentPoint)
          Adds the specified point provided it is not already an adjacent member.
 void addAdjacentPoints(java.util.Vector<Point3D> adjacentPoints)
          Adds the specified vector of points.
 int[] adjacentPointIDs()
          Returns an array of this object's adjacent point IDs.
 int adjacentPointIndex(Point3D adjacentPoint)
          Returns the adjacentPoints index of the specified adjacent point, or -1 if adjacentPoint is null or index not identified.
 java.util.Vector<Point3D> adjacentPointsInCommon(Point3DWithAdjacentPoints adjacentPoint)
          Returns a vector of points whose adjacencies are shared between this point and the specified point
 FloatingPointVector anglesBetweenThisPointAndAdjacentPoints(boolean degrees)
          Returns a vector of angles between this point and it's adjacent points.
 Point3D centroidOfAdjacentPoints()
          Returns the centroid of this point's adjacent points.
 Point3D centroidOfThisPointAndAdjacentPoints()
          Returns the centroid of this point and its adjacent points.
 java.util.Vector<ModelObject> childModelObjects()
          Returns a vector of this object's child ModelObject objects.
 java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection, int modelID)
          Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database.
 java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection, int modelID)
          Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.
 double distanceSumToAdjacentPoints(boolean distanceSquared)
          Returns the total distance from this point to all adjacent specified points.
 double distanceToAdjacentPoint(int adjacentPointIndex, boolean distanceSquared)
          Returns the distance from this point to the specified point.
 double distanceToAdjacentPoint(Point3D adjacentPoint, boolean distanceSquared)
          Returns the distance from this point to the specified adjacent point.
 ModelObject fromDatabase(java.sql.Connection connection, Model model, int modelID, int objectID)
          Returns a model object from the specified database table.
 ModelObject fromXMLNode(org.w3c.dom.Document document, org.w3c.dom.Node documentRootNode, org.w3c.dom.Node node, Model model)
          Returns a model object from the specified xml node.
 java.util.Vector<Point3D> getAdjacentPoints()
          Returns the vector of adjacent points.
 boolean hasAdjacentPoints()
          Tests whether or not this point has adjacent points.
 boolean isAdjacentPoint(Point3D adjacentPoint)
          Tests whether or not the specified point is in the vector of adjacent points.
 boolean isAdjacentPointIndex(int adjacentPoint)
          Tests whether or not the specified adjacent point index is valid.
 int numberAdjacentPoints()
          Returns the number of adjacent points.
 boolean sameSense(Point3DWithAdjacentPoints originalPoint, double tolerance)
          Tests whether or not this point has the same sense as the specified point.
 void setAdjacentPoints(java.util.Vector<Point3D> adjacentPoints)
          Sets the vector of adjacent points to the specified vector.
 void setToCentroidOfAdjacentPoints()
          Sets this point to the centroid of it's adjacent points.
 java.lang.String toString()
          Returns a String representation of a Point3DWithAdjacentPoints object.
 org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document, org.w3c.dom.Element documentRootNode)
          Returns the xml node of this object.
 
Methods inherited from class com.hedgehog.geo.threed.points.Point3D
addTo, addTo, addToX, addToY, addToZ, areaCoordinates, areaOfTriangleFormedByThreePoints, averagePoint, averagePoint, averagePoint, clone, contains, copy, distanceBetweenTwoPoints, distanceFromGlobalOrigin, distanceSquaredBetweenTwoPoints, distanceSquaredFromGlobalOrigin, divide, divideBy, equals, equals, furthestGloablOrigin, furthestPoint, furthestPoint, furthestPoint, get, getCoordinate, getDimensions, getThreeNonCollinearPoints, getX, getY, getZ, interpolation, interpolation, interpolation, interpolation, is2D, is3D, isAtGlobalOrigin, isCollinear, isCollinear, isCoplanar, isCoplanar, isCurve, isFinitePoint, isGrid, isInXYPlane, isInXZPlane, isInYZPlane, isMesh, isPoint, isPointOnInfiniteStraightLine, isPointOnPlane, isPointSet, isShape, isSurface, isValid, isWithin, makeNotAPoint, maximumX, maximumY, maximumZ, midPoint, minimumDistance, minimumX, minimumY, minimumZ, multiply, multiplyBy, nearestGloablOrigin, nearestPoint, nearestPoint, nearestPoint, negate, parametricVariable, pointAlongVector, projectedPoint, projection, projectOntoXYPlane, projectOntoXZPlane, projectOntoYZPlane, reflectionAboutXAxisInXYPlane, reflectionAboutXAxisInZXPlane, reflectionAboutYAxisInXYPlane, reflectionAboutYAxisInYZPlane, reflectionAboutZAxisInYZPlane, reflectionAboutZAxisInZXPlane, reflectionMatrixAboutXAxisInXYPlane, reflectionMatrixAboutXAxisInZXPlane, reflectionMatrixAboutYAxisInXYPlane, reflectionMatrixAboutYAxisInYZPlane, reflectionMatrixAboutZAxisInYZPlane, reflectionMatrixAboutZAxisInZXPlane, reflectionMatrixThroughOrigin, reflectionMatrixThroughXAxis, reflectionMatrixThroughYAxis, reflectionMatrixThroughZAxis, reflectionThroughOrigin, reflectionThroughXAxis, reflectionThroughYAxis, reflectionThroughZAxis, rotatedPoint, rotateFromLocalToGlobalAxes, rotationAboutAxis, rotationInXYCoordinatePlane, rotationInYZCoordinatePlane, rotationInZXCoordinatePlane, rotationMatrix, rotationMatrixInXYCoordinatePlane, rotationMatrixInYZCoordinatePlane, rotationMatrixInZXCoordinatePlane, samePoint, scaledPoint, set, set, set, set, setX, setY, setZ, sortByCoordinate, sortByDistanceToGlobalOrigin, sortByDistanceToPoint, subtract, subtractFrom, subtractFrom, subtractFromX, subtractFromY, subtractFromZ, swapXY, swapXZ, swapYZ, toArray, toFloatingPointVector, toTriple, toVector3D, toX3DNode, transform, translate, translate, translatedPoint, translatedPoint, unique, unique, volumeCoordinates, volumeCoordinates
 
Methods inherited from class com.hedgehog.geo.GeometricObject
objectDimension
 
Methods inherited from class com.hedgehog.HObject
compare, compareTo, getID, getName, hashCode, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hedgehog.model.ModelObject
toX3DNode
 

Field Detail

mAdjacentPoints

protected java.util.Vector<Point3D> mAdjacentPoints
Vector of adjacent points.

Constructor Detail

Point3DWithAdjacentPoints

public Point3DWithAdjacentPoints()
Default constructor. Sets the (x,y,z)=(0,0,0) and the adjacent-points vector to a new non-null empty vector..


Point3DWithAdjacentPoints

public Point3DWithAdjacentPoints(double x,
                                 double y,
                                 double z)
Constructor. Sets the adjacent-points vector to a new non-null empty vector.

Parameters:
x - x-coordinate of point.
y - y-coordinate of point.
z - z-coordinate of point.

Point3DWithAdjacentPoints

public Point3DWithAdjacentPoints(double x,
                                 double y,
                                 double z,
                                 java.util.Vector<Point3D> adjacentPoints)
Constructor.

Parameters:
x - x-coordinate of point.
y - y-coordinate of point.
z - z-coordinate of point.
adjacentPoints - Vector of adjacent points.

Point3DWithAdjacentPoints

public Point3DWithAdjacentPoints(Point3DWithAdjacentPoints object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getAdjacentPoints

public java.util.Vector<Point3D> getAdjacentPoints()
Returns the vector of adjacent points.

Returns:
The vector of adjacent points.

setAdjacentPoints

public void setAdjacentPoints(java.util.Vector<Point3D> adjacentPoints)
Sets the vector of adjacent points to the specified vector.

Parameters:
adjacentPoints - New vector of adjacent points.

addAdjacentPoint

public boolean addAdjacentPoint(Point3D adjacentPoint)
Adds the specified point provided it is not already an adjacent member.

Parameters:
adjacentPoint - Point to add.
Returns:
Logical-true if the specified point is added, else logical-false.

addAdjacentPoints

public void addAdjacentPoints(java.util.Vector<Point3D> adjacentPoints)
Adds the specified vector of points. Only adds a point provided it is not already an adjacent member.

Parameters:
adjacentPoints - Vector of points to add.

hasAdjacentPoints

public boolean hasAdjacentPoints()
Tests whether or not this point has adjacent points.

Returns:
Logical-true if this point has adjacent points, else logical-false.

adjacentPointsInCommon

public java.util.Vector<Point3D> adjacentPointsInCommon(Point3DWithAdjacentPoints adjacentPoint)
                                                 throws java.lang.IllegalArgumentException
Returns a vector of points whose adjacencies are shared between this point and the specified point

Parameters:
adjacentPoint - Point to test for common adjacent points with this point.
Returns:
Vector of common adjacent points.
Throws:
java.lang.IllegalArgumentException - Thrown if adjacentPoint is null.

anglesBetweenThisPointAndAdjacentPoints

public FloatingPointVector anglesBetweenThisPointAndAdjacentPoints(boolean degrees)
Returns a vector of angles between this point and it's adjacent points. The order of vector of angles is equivalent to that of the encapsulated adjacent points. Note1: The number of returned angles is equal to the number of adjacent points; ie circular list of angles. Note2: If there are no adjacent points then an empty vector is returned. Note3: If there is 1 adjacent point then the single angle 360 is returned.

Parameters:
degrees - Specified whether the returned angles are in degree or radians; default is DEGREES.
Returns:
Vector of angles subtended between this point and its adjacent points.

numberAdjacentPoints

public int numberAdjacentPoints()
Returns the number of adjacent points.

Returns:
The number of adjacent points.

centroidOfThisPointAndAdjacentPoints

public Point3D centroidOfThisPointAndAdjacentPoints()
Returns the centroid of this point and its adjacent points.

Returns:
Centroid of this point and its adjacent points.

centroidOfAdjacentPoints

public Point3D centroidOfAdjacentPoints()
Returns the centroid of this point's adjacent points. If this point has no adjacent points then this point is returned, so it is probably best to test whether this point has any adjacent points beforehand.

Returns:
Centroid of this point's adjacent points.

adjacentPointIndex

public int adjacentPointIndex(Point3D adjacentPoint)
Returns the adjacentPoints index of the specified adjacent point, or -1 if adjacentPoint is null or index not identified.

Parameters:
adjacentPoint - Adjacent point.
Returns:
Index into vector adjacentPoints corresponding to adjacentPoint or -1 if not located.

distanceToAdjacentPoint

public double distanceToAdjacentPoint(int adjacentPointIndex,
                                      boolean distanceSquared)
                               throws java.lang.IllegalArgumentException
Returns the distance from this point to the specified point.

Parameters:
adjacentPointIndex - Adjacent point index.
distanceSquared - Specifies whether or not the returned distance is to be squared (saving a sqrt() call) or actual distance; default is false.
Returns:
Distance between this point and the specified adjacent point.
Throws:
java.lang.IllegalArgumentException - Thrown if adjacentPoint is invalid.

distanceToAdjacentPoint

public double distanceToAdjacentPoint(Point3D adjacentPoint,
                                      boolean distanceSquared)
                               throws java.lang.IllegalArgumentException
Returns the distance from this point to the specified adjacent point.

Parameters:
adjacentPoint - Adjacent point.
distanceSquared - Specifies whether or not the returned distance is to be squared (saving a sqrt() call) or actual distance; default is false.
Returns:
Distance between this point and the specified adjacent point.
Throws:
java.lang.IllegalArgumentException - Thrown if adjacentPoint is invalid.

distanceSumToAdjacentPoints

public double distanceSumToAdjacentPoints(boolean distanceSquared)
Returns the total distance from this point to all adjacent specified points.

Parameters:
distanceSquared - Specifies whether or not the returned distance is to be squared (saving a sqrt() call) or actual distance; default is false.
Returns:
Total distance between this point and all adjacent points.

sameSense

public boolean sameSense(Point3DWithAdjacentPoints originalPoint,
                         double tolerance)
                  throws java.lang.IllegalArgumentException
Tests whether or not this point has the same sense as the specified point. For this point's "sense" to be the same as that of originalPoint then the sign of the cross-product of this point and its adjacent points must be the same as that of originalPoint for the same triple of points. Note1 It is assumed that the ordering of this point's adjacent points is the same as that or originalPoint, even though they may have different geometric positions.

Parameters:
originalPoint - Original point and adjacent points to compare against this point.
tolerance - Required tolerance.
Returns:
Logical-true if this point has the same sense as the specified original point.
Throws:
java.lang.IllegalArgumentException - Thrown if originalPoint has a different number of adjacent points to this point.

isAdjacentPoint

public boolean isAdjacentPoint(Point3D adjacentPoint)
Tests whether or not the specified point is in the vector of adjacent points.

Parameters:
adjacentPoint - Adjacent point to test.
Returns:
Logical-true if the specified point is in this point's adjaent vector, else logical-false.

isAdjacentPointIndex

public boolean isAdjacentPointIndex(int adjacentPoint)
Tests whether or not the specified adjacent point index is valid.

Parameters:
adjacentPoint - Adjacent point index.
Returns:
Logical-true if adjacentPoint is valid, else logical-false.

setToCentroidOfAdjacentPoints

public void setToCentroidOfAdjacentPoints()
Sets this point to the centroid of it's adjacent points. Effectively a Laplacian smoothing of this point.


toString

public java.lang.String toString()
Returns a String representation of a Point3DWithAdjacentPoints object.

Overrides:
toString in class Point3D
Returns:
A String representation of a Point3DWithAdjacentPoints object.

childModelObjects

public java.util.Vector<ModelObject> childModelObjects()
Returns a vector of this object's child ModelObject objects.

Specified by:
childModelObjects in interface ModelObject
Overrides:
childModelObjects in class Point3D
Returns:
A vector consisting of this object's adjacent points.

adjacentPointIDs

public int[] adjacentPointIDs()
Returns an array of this object's adjacent point IDs.

Returns:
An array of this object's adjacent point IDs.

databaseInsertStatement

public java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection,
                                                          int modelID)
                                                   throws java.sql.SQLException
Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database.

Specified by:
databaseInsertStatement in interface ModelObject
Overrides:
databaseInsertStatement in class Point3D
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

databaseUpdateStatement

public java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection,
                                                          int modelID)
                                                   throws java.sql.SQLException
Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.

Specified by:
databaseUpdateStatement in interface ModelObject
Overrides:
databaseUpdateStatement in class Point3D
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

fromDatabase

public ModelObject fromDatabase(java.sql.Connection connection,
                                Model model,
                                int modelID,
                                int objectID)
                         throws java.sql.SQLException
Returns a model object from the specified database table.

Specified by:
fromDatabase in interface ModelObject
Overrides:
fromDatabase in class Point3D
Parameters:
connection - Database connection.
modelID - Model ID.
objectID - Object ID in associated ModelObjects table.
model - Model built from database.
Returns:
ModelObject corresponding to the specified db connection, model ID and obect ID. A null value is returned if no match found.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

toXMLNode

public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
                                     org.w3c.dom.Element documentRootNode)
                              throws InvalidObjectException
Returns the xml node of this object.

Specified by:
toXMLNode in interface ModelObject
Overrides:
toXMLNode in class Point3D
Parameters:
document - XML document.
documentRootNode - Document root node.
Returns:
The xml node of this object.
Throws:
InvalidObjectException - Thrown if this object's ID is equal to the default ID of -1.

fromXMLNode

public ModelObject fromXMLNode(org.w3c.dom.Document document,
                               org.w3c.dom.Node documentRootNode,
                               org.w3c.dom.Node node,
                               Model model)
                        throws InvalidObjectException
Returns a model object from the specified xml node.

Specified by:
fromXMLNode in interface ModelObject
Overrides:
fromXMLNode in class Point3D
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
node - XML node.
model - The model to which the returned object is associated.
Returns:
ModelObject corresponding to the specified node. A null value is returned if an error occurred building the object.
Throws:
InvalidObjectException - Thrown if an error occurred building the object.