com.hedgehog.geo.threed.curves
Class Ray3D

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.geo.GeometricObject
          extended by com.hedgehog.geo.threed.curves.Curve3D
              extended by com.hedgehog.geo.threed.curves.Ray3D
All Implemented Interfaces:
ModelObject, java.lang.Comparable, java.util.Comparator

public class Ray3D
extends Curve3D
implements ModelObject

Title: Ray3D - models a 3D ray.

Description: Represents a 3D ray. The ray is represented as P+t*D, where P is the ray origin, D is a unit-length direction vector, and t >= 0. The user must ensure that the direction vector satisfies this condition.

Although Ray3D encapsulates its own origina poit, it does make use of Curve2D's end-points mp0 and mp1.

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

Company: Hedgehog Software

Since:
1.0
Version:
1.1

Field Summary
protected  Vector3D mDirection
          Ray direction.
protected  Point3D mOrigin
          Ray origin.
 
Fields inherited from class com.hedgehog.geo.threed.curves.Curve3D
mp0, mp1
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
Ray3D()
          Default constructor.
Ray3D(ID id)
          Constructor.
Ray3D(Point3D origin, Point3D otherPoint)
          Constructor.
Ray3D(Point3D origin, Vector3D direction)
          Constructor.
Ray3D(Point3D origin, Vector3D direction, java.lang.String name, ID id)
          Constructor.
Ray3D(Ray3D object)
          Copy constructor.
Ray3D(java.lang.String name)
          Constructor.
Ray3D(java.lang.String name, ID id)
          Sets the origin to (0,0,0), direction to (1,0,0), end-point mp0 to the ray origin and mp1 to null.
 
Method Summary
 java.util.Vector<ModelObject> childModelObjects()
          Returns a vector of this object's child ModelObject objects.
 Curve3D copy()
          Returns a copy of this Ray3D object.
 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 distanceTo(Point3D p)
          Returns the distance from the specified point to this ray.
 double distanceTo(Ray3D ray1, double tolerance, Point3D ray0ClosestPoint, Point3D ray1ClosestPoint)
          Returns the minimum distance between this ray (ray0) and the specified ray (ray1).
 double distanceToSquared(Point3D p)
          Returns the distance squared from the specified point to this ray.
 double distanceToSquared(Ray3D ray1, double tolerance, Point3D ray0ClosestPoint, Point3D ray1ClosestPoint)
          Returns the minimum distance squared between this ray (ray0) and the specified ray (ray1).
 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.
 Vector3D getDirection()
          Returns the ray direction.
 Point3D getOrigin()
          Returns the ray origin.
 Point3D intermediatePoint(double c1, double c2)
          Returns an intermediate point which divides a straight line in the ratio c1/c2 p0-p:p-p1 is c1:c2, c1!=-c2.
 void intermediatePoint(Point3D p, HDouble c1, HDouble c2)
          Returns, via reference, the distances c1 and c2 from origin to p and p to end-of ray.
 Point3D intersection(Ray3D ray, double tolerance)
          Returns the point of intersection between two rays-if any.
 boolean isParallelToXAxis(double tolerance)
          Tests whether or not this vector is parallel to the x-axis.
 boolean isParallelToYAxis(double tolerance)
          Tests whether or not this vector is parallel to the y-axis.
 boolean isParallelToZAxis(double tolerance)
          Tests whether or not this vector is parallel to the z-axis.
 boolean isSelfIntersecting()
          Returns false since a ray cannot self-intersect.
 boolean isValid()
          Tests the validity of this vector.
 double length()
          Returns the length of a ray; Tolerances.POSITIVE_INFINITE.
 void lengthCoordinates(Point3D p, HDouble zeta1, HDouble zeta2)
          Sets both zeta1 and zeta2 to 0 since length coordinates are undefined because the ray length is infinite.
 Point3D midPoint()
          Returns null since the mid-point of a ray is undefined.
 double minimumDistance(Point3D p, double tolerance)
          Returns the minimum distance from the specified point to this ray.
 void normaliseDirectionVector()
          Normalises the direction vector of this ray.
 double parametricVariable(Point3D p, double tolerance)
          Returns the value of the parametric variable, t, corresponding to the specified point.
 boolean pointOfCurve(Point3D p, double tolerance)
          Tests if the specified point is a point of this ray; ie if p is identical to the ray origin.
 Point3D pointOnCurve(double t, double tolerance)
          Returns a point on the ray given the parametric variable.
 boolean pointOnCurve(Point3D p, double tolerance)
          Tests whether or not the specified point is on this ray.
 java.util.ArrayList<Point3D> pointsOnRay(Point3D startPoint, Point3D endPoint, double distanceBetweenPoints)
          Returns a vector of points between the specified start and end points on this ray.
 Point3D projectPointOntoRay(Point3D p)
          Projects the specified point orthogonally onto this ray.
static Ray3D rayThroughPointSet(Point3DSet pset)
           Returns a Ray3D object that passes through the specified point set.
 void reverse()
          Reverses the direction of this ray.
 Curve3D rotate(double theta, double beta, double gamma, Point3D fixedPoint, boolean degrees)
          Rotates this ray.
 Curve3D scale(double s, Point3D fixedPoint)
          Scales this ray by scaling the ray origin.
 Vector3D secondDerivative(double u)
          Returns the second derivative; ie Vector3D.ZERO.
 void setDirection(Vector3D direction)
          Sets the ray direction vector.
 void setOrigin(Point3D origin)
          Sets the ray origin.
 Vector3D tangent(double u)
          Returns the tangent vector at the specified parametric-variable value.
 Vector3D tangent(Point3D p)
          Returns the tangent vector at the specified point.
 Ray3D toLocalCoordinateSystem(OrthogonalCoordinateSystem3D ocs)
          Converts this ray (wrt global coordinates) to the specified local coordinate system.
 double torsion(double u)
          Returns the torsion; ie 0.0 for a ray of constant direction vector.
 java.lang.String toString()
          Returns a String representation of an Ray3D object.
 X3DNode toX3DNode(X3DObject x3dObject)
          X3D support.
 org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document, org.w3c.dom.Element doucmentRootNode)
          Returns the xml node of this object.
 void transform(Matrix4x4 matrix)
          Applies the specified transformation matrix to this curve.
 Curve3D translate(double tx, double ty, double tz)
          Returns this ray translated through the specified (tx,ty,tz) translation vector.
 
Methods inherited from class com.hedgehog.geo.threed.curves.Curve3D
commonEndPoint, curvature, curvePoints, distanceBetweenTwoPointsAlongCurve, distanceBetweenTwoPointsAlongCurve, equals, evenlySpacedIntermediatePoints, geodesicCurvature, getP0, getP1, interpolation, is2D, is3D, isCurve, isEndPoint, isEndPointP0, isEndPointP1, isGrid, isMesh, isOpen, isPoint, isPointSet, isShape, isSurface, isZeroLength, jacobian, jacobian, length, lengthCoordinates, lengthFunction, nearestEndPoint, nearestEndPoint, nearestPoint, nearestPointApprox, nearestPointParametricVariable, normalPlane, osculatingPlane, otherEndPoint, pointsOnCurve, randomPoint, rectifyingPlane, sameCurve, sameEndPoints, setP0, setP1, shapeFunctions, shapeFunctions, shapeFunctionsDerivatives, shareEndPoint, trihedron, unitBiNormalVector, unitPrincipalNormalVector
 
Methods inherited from class com.hedgehog.geo.GeometricObject
objectDimension
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, getID, getName, hashCode, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mOrigin

protected Point3D mOrigin
Ray origin.


mDirection

protected Vector3D mDirection
Ray direction.

Constructor Detail

Ray3D

public Ray3D()
Default constructor. Sets the origin to (0,0,0), direction to (1,0,0), end-point mp0 to the ray origin and mp1 to null.


Ray3D

public Ray3D(Point3D origin,
             Vector3D direction)
      throws java.lang.IllegalArgumentException
Constructor. Sets the origin and direction to the specified objects.

Parameters:
origin - Ray origin.
direction - Ray direction.
Throws:
java.lang.IllegalArgumentException - Thrown if origin or direction are null or if direction is not of unit length.

Ray3D

public Ray3D(Point3D origin,
             Vector3D direction,
             java.lang.String name,
             ID id)
      throws java.lang.IllegalArgumentException
Constructor. Sets the origin and direction to the specified objects.

Parameters:
origin - Ray origin.
direction - Ray direction.
name - Object name.
id - Object ID.
Throws:
java.lang.IllegalArgumentException - Thrown if origin or direction are null or if direction is not of unit length.

Ray3D

public Ray3D(Point3D origin,
             Point3D otherPoint)
      throws java.lang.IllegalArgumentException
Constructor. Sets the origin to the specified object and computes the direction from the vector (origin-otherPoint).

Parameters:
origin - Ray origin.
otherPoint - Othe point from which to compute ray direction.
Throws:
java.lang.IllegalArgumentException - Thrown if origin or otherPoint are null. or if origin to otherPoint are the same point within hedgehog.utility.Tolerances.TOLERANCE.

Ray3D

public Ray3D(java.lang.String name)
Constructor. Sets the origin to (0,0,0), direction to (1,0,0), end-point mp0 to the ray origin and mp1 to null.

Parameters:
name - Ray name.

Ray3D

public Ray3D(ID id)
Constructor. Sets the origin to (0,0,0), direction to (1,0,0), end-point mp0 to the ray origin and mp1 to null.

Parameters:
id - Ray ID.

Ray3D

public Ray3D(java.lang.String name,
             ID id)
Sets the origin to (0,0,0), direction to (1,0,0), end-point mp0 to the ray origin and mp1 to null.

Parameters:
name - Ray name.
id - Ray ID.

Ray3D

public Ray3D(Ray3D object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getOrigin

public Point3D getOrigin()
Returns the ray origin.

Returns:
Ray origin.

getDirection

public Vector3D getDirection()
Returns the ray direction.

Returns:
Ray direction.

setOrigin

public void setOrigin(Point3D origin)
Sets the ray origin.

Parameters:
origin - New ray origin.

setDirection

public void setDirection(Vector3D direction)
Sets the ray direction vector.

Parameters:
direction - new ray direction.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified direction vector is null or not of unit length.

copy

public Curve3D copy()
Returns a copy of this Ray3D object.

Overrides:
copy in class HObject
Returns:
A copy of this ray.

intermediatePoint

public Point3D intermediatePoint(double c1,
                                 double c2)
                          throws java.lang.IllegalArgumentException
Returns an intermediate point which divides a straight line in the ratio c1/c2 p0-p:p-p1 is c1:c2, c1!=-c2. Actually returns null since method is undefined for a ray of infinite length.

Parameters:
c1 - Numerator value.
c2 - Denomiator value.
Returns:
A null value since undefined for an infinute ray.
Throws:
java.lang.IllegalArgumentException - Thrown if ||c1+c2||

intermediatePoint

public void intermediatePoint(Point3D p,
                              HDouble c1,
                              HDouble c2)
                       throws java.lang.IllegalArgumentException
Returns, via reference, the distances c1 and c2 from origin to p and p to end-of ray.

Parameters:
p - Point to determine distance from.
c1 - Set upon return to the distance between origin and p.
c2 - Set upon return to POSITIVE_INFINITE since a has infinite length.
Throws:
java.lang.IllegalArgumentException - Thrown if p does not lie on this ray.

intersection

public Point3D intersection(Ray3D ray,
                            double tolerance)
Returns the point of intersection between two rays-if any.

Parameters:
ray - Other ray to test for intersection.
tolerance - Required tolerance.
Returns:
Intersection point (if any), else null if no intersection.

isSelfIntersecting

public boolean isSelfIntersecting()
Returns false since a ray cannot self-intersect.

Returns:
Logical-false since a ray cannot self-intersect.

isValid

public boolean isValid()
Tests the validity of this vector.

Returns:
Logical-true if valid, else logical-false if null origin and/or zero length direction vector.

isParallelToXAxis

public boolean isParallelToXAxis(double tolerance)
Tests whether or not this vector is parallel to the x-axis.

Parameters:
tolerance - Required tolerance.
Returns:
Logical-true if this vector is parallel to the x-axis, else logical-false.

isParallelToYAxis

public boolean isParallelToYAxis(double tolerance)
Tests whether or not this vector is parallel to the y-axis.

Parameters:
tolerance - Required tolerance.
Returns:
Logical-true if this vector is parallel to the y-axis, else logical-false.

isParallelToZAxis

public boolean isParallelToZAxis(double tolerance)
Tests whether or not this vector is parallel to the z-axis.

Parameters:
tolerance - Required tolerance.
Returns:
Logical-true if this vector is parallel to the z-axis, else logical-false.

lengthCoordinates

public void lengthCoordinates(Point3D p,
                              HDouble zeta1,
                              HDouble zeta2)
                       throws java.lang.IllegalArgumentException
Sets both zeta1 and zeta2 to 0 since length coordinates are undefined because the ray length is infinite.

Parameters:
p - Point to determine length coordinates.
zeta1 - Set upon return to length coordinate 1.
zeta2 - Set upon return to length coordinate 2.
Throws:
java.lang.IllegalArgumentException - Thrown if p not on this ray.

toLocalCoordinateSystem

public Ray3D toLocalCoordinateSystem(OrthogonalCoordinateSystem3D ocs)
Converts this ray (wrt global coordinates) to the specified local coordinate system.

Parameters:
ocs - Coordinate system.
Returns:
This ray wrt the specified local coordinate system.

length

public double length()
Returns the length of a ray; Tolerances.POSITIVE_INFINITE.

Overrides:
length in class Curve3D
Returns:
Length of this ray; ie Tolerances.POSITIVE_INFINITE.

minimumDistance

public double minimumDistance(Point3D p,
                              double tolerance)
Returns the minimum distance from the specified point to this ray.

Overrides:
minimumDistance in class Curve3D
Parameters:
p - Point.
tolerance - Required tolerance.
Returns:
Minimum distance from the specified point to this ray.

distanceToSquared

public double distanceToSquared(Point3D p)
Returns the distance squared from the specified point to this ray. If the projection of the point lies on the ray then this perpendicular distance squared is returned. If the point lies behind the ray origin then the straight line distance squared between the ray origin and point is returned.

Parameters:
p - Point.
Returns:
Distance squared from this ray to the specified point.

distanceTo

public double distanceTo(Point3D p)
Returns the distance from the specified point to this ray. If the projection of the point lies on the ray then this perpendicular distance is returned. If the point lies behind the ray origin then the straight line distance between the ray origin and point is returned.

Parameters:
p - Point.
Returns:
Distance from this ray to the specified point.

normaliseDirectionVector

public void normaliseDirectionVector()
Normalises the direction vector of this ray.

Since:
1.1

distanceToSquared

public double distanceToSquared(Ray3D ray1,
                                double tolerance,
                                Point3D ray0ClosestPoint,
                                Point3D ray1ClosestPoint)
Returns the minimum distance squared between this ray (ray0) and the specified ray (ray1).

Parameters:
ray1 - Other ray.
tolerance - Required tolerance.
ray0ClosestPoint - Set upon return to the point on this ray that is closest to the specified ray.
ray1ClosestPoint - Set upon return to the point on the specified ray that is closest to this ray.
Returns:
The minimum distance squared.
Since:
1.1

distanceTo

public double distanceTo(Ray3D ray1,
                         double tolerance,
                         Point3D ray0ClosestPoint,
                         Point3D ray1ClosestPoint)
Returns the minimum distance between this ray (ray0) and the specified ray (ray1).

Parameters:
ray1 - Other ray.
tolerance - Required tolerance.
ray0ClosestPoint - Set upon return to the point on this ray that is closest to the specified ray.
ray1ClosestPoint - Set upon return to the point on the specified ray that is closest to this ray.
Returns:
The minimum distance.
Since:
1.1

midPoint

public Point3D midPoint()
Returns null since the mid-point of a ray is undefined.

Overrides:
midPoint in class Curve3D
Returns:
A null value since the mid-point of a ray is undefined.

parametricVariable

public double parametricVariable(Point3D p,
                                 double tolerance)
                          throws java.lang.IllegalArgumentException
Returns the value of the parametric variable, t, corresponding to the specified point.

Overrides:
parametricVariable in class Curve3D
Parameters:
p - Point to determine parametric variable value.
tolerance - Required tolerance.
Returns:
Parametric variable distance of end-point p0 to the specified point, p. If an error occurs in OneVariableFunction.optimisationBFGS() then a value of -1.0 is returned.
Throws:
java.lang.IllegalArgumentException - Thrown if p is not on this ray.

pointsOnRay

public java.util.ArrayList<Point3D> pointsOnRay(Point3D startPoint,
                                                Point3D endPoint,
                                                double distanceBetweenPoints)
                                         throws java.lang.IllegalArgumentException
Returns a vector of points between the specified start and end points on this ray. The distance between the points is speicfied by distanceBetweenPoints. The returned vector includes both the start and end points.

Parameters:
startPoint - Strat point.
endPoint - End point.
distanceBetweenPoints - Distance between intermediate points.
Returns:
Vector of points on this ray.
Throws:
java.lang.IllegalArgumentException - Thrown if endPoint is before startPoint, startPoint and endPoint are the same point or distanceBetweenPoints is greater than the distance between the start and end point.

pointOfCurve

public boolean pointOfCurve(Point3D p,
                            double tolerance)
Tests if the specified point is a point of this ray; ie if p is identical to the ray origin.

Overrides:
pointOfCurve in class Curve3D
Parameters:
p - Point to test.
tolerance - Required tolerance.
Returns:
Logical-true if p is located at the same coordinates as this ray origin, else logical-false.

pointOnCurve

public boolean pointOnCurve(Point3D p,
                            double tolerance)
Tests whether or not the specified point is on this ray. A point on the negative side (-ve parametric variable value) of this ray is not considered to be on the ray.

Specified by:
pointOnCurve in class Curve3D
Parameters:
p - Point to test.
tolerance - Required tolerance.
Returns:
Logical-true if p is on this ray, else logical-false.

pointOnCurve

public Point3D pointOnCurve(double t,
                            double tolerance)
                     throws java.lang.IllegalArgumentException
Returns a point on the ray given the parametric variable. Note: a PointOnCurveException is thrown if t<0. If a -ve t value is required then flip the direction of the ray using reverse().

Specified by:
pointOnCurve in class Curve3D
Parameters:
t - Parametric distance along ray from ray origin.
tolerance - Required tolerance used to test if the value of t is approximately 0 and hence at the ray origin.
Returns:
Point on ray at specified t value.
Throws:
java.lang.IllegalArgumentException - Thrown if invalid t.

rayThroughPointSet

public static Ray3D rayThroughPointSet(Point3DSet pset)
                                throws java.lang.IllegalArgumentException,
                                       InvalidObjectException

Returns a Ray3D object that passes through the specified point set. The method used is a least squares fit through the point set minimising the orthogonal distance from the ray to the point set.

The ray origin is set to the point set centroid. The ray direction may not be expected, and if, for example, testing the generated ray for intersection with a plane then simply test the ray in both direcitons using Ray3D.reverse().

Note that no test is performed as to whether or not the point set consists of distinct points. If the number of points is equal to 2 and they are at the same position then an IllegalArgumentException will be thrown when building the ray. No such catch will occur for more than 2 points at the same position, so ensure that the point set is distributed. The only requirement is at least 2 points are distinct, which will generally be the case.

Parameters:
pset - Point set.
Returns:
Ray3D passing through the specified point set.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified point set is null or has less than 2 points.
InvalidObjectException - Thrown if an internal error occurred performing the eigenvector solution of the least squares fit.

projectPointOntoRay

public Point3D projectPointOntoRay(Point3D p)
Projects the specified point orthogonally onto this ray.

Parameters:
p - Point to project.
Returns:
Projected point.
Since:
1.1

reverse

public void reverse()
Reverses the direction of this ray.

Overrides:
reverse in class Curve3D

scale

public Curve3D scale(double s,
                     Point3D fixedPoint)
Scales this ray by scaling the ray origin.

Specified by:
scale in class Curve3D
Parameters:
s - Scaling factor.
fixedPoint - Fixed point about which scaling occurs. If null then scaling is with respect to the global origin.
Returns:
Scaled ray.

rotate

public Curve3D rotate(double theta,
                      double beta,
                      double gamma,
                      Point3D fixedPoint,
                      boolean degrees)
               throws java.lang.IllegalArgumentException
Rotates this ray.

Specified by:
rotate in class Curve3D
Parameters:
theta - Angle about z-axis. Must be in range [0:360] degrees or [0:2pi] radians.
beta - Angle about y-axis. Must be in range [0:360] degrees or [0:2pi] radians.
gamma - Angle about x-axis. Must be in range [0:360] degrees or [0:2pi] radians.
fixedPoint - If null then the rotation is wrt the global origin (0,0,0), else wrt the specified point.
degrees - Specifies whether or not the 3 angles theta, beta and gamma are in degrees or radians.
Returns:
Rotated ray.
Throws:
java.lang.IllegalArgumentException - Thrown if invalid angles specified.

secondDerivative

public Vector3D secondDerivative(double u)
                          throws java.lang.IllegalArgumentException
Returns the second derivative; ie Vector3D.ZERO.

Overrides:
secondDerivative in class Curve3D
Parameters:
u - Parametric-variable value on this ray.
Returns:
Second derivative vector; ie Vector3D.ZERO.
Throws:
java.lang.IllegalArgumentException - Thrown if u is out of range [0:infinity].

toString

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

Overrides:
toString in class Curve3D
Returns:
A String representation of an Ray3D object.

tangent

public Vector3D tangent(double u)
                 throws java.lang.IllegalArgumentException
Returns the tangent vector at the specified parametric-variable value.

Overrides:
tangent in class Curve3D
Parameters:
u - Parametric-variable value.
Returns:
Tangent; ie the ray direction.
Throws:
java.lang.IllegalArgumentException - Thrown if u is out of range [0:infinity].

tangent

public Vector3D tangent(Point3D p)
Returns the tangent vector at the specified point.

Overrides:
tangent in class Curve3D
Parameters:
p - Point on ray.
Returns:
Tangent; ie the ray direction.

torsion

public double torsion(double u)
               throws java.lang.IllegalArgumentException
Returns the torsion; ie 0.0 for a ray of constant direction vector.

Overrides:
torsion in class Curve3D
Parameters:
u - Parametric-variable value.
Returns:
Torsion at u.
Throws:
java.lang.IllegalArgumentException - Thrown if u is out of range [0:infinity].

translate

public Curve3D translate(double tx,
                         double ty,
                         double tz)
Returns this ray translated through the specified (tx,ty,tz) translation vector.

Specified by:
translate in class Curve3D
Parameters:
tx - Translation in x-direction.
ty - Translation in y-direction.
tz - Translation in z-direction.
Returns:
Translated ray.

childModelObjects

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

Specified by:
childModelObjects in interface ModelObject
Returns:
A vector consisting of this object's origin and direction vector.

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

toXMLNode

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

Specified by:
toXMLNode in interface ModelObject
Parameters:
document - XML document.
doucmentRootNode - Doucmnet 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
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
node - XML node.
model - The model to which this object is added.
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.

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

toX3DNode

public X3DNode toX3DNode(X3DObject x3dObject)
                  throws InvalidObjectException
X3D support.

Specified by:
toX3DNode in interface ModelObject
Parameters:
x3dObject - X3D object.
Returns:
X3D object or null if object has no visualisation.
Throws:
InvalidObjectException - Thrown if this object is invalid.

transform

public void transform(Matrix4x4 matrix)
Applies the specified transformation matrix to this curve. Refer to the static methods of Matix4x4 for standard transformation matrices. The transformation is applied to the ray origina only. Transformation of the ray direction must be down separately. Note that the transformation is applied to this ray's origina so that if any other objects share this point then they too will be transformed.

Overrides:
transform in class Curve3D
Parameters:
matrix - Transformation matrix.