|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.geo.GeometricObject
com.hedgehog.geo.threed.curves.Curve3D
com.hedgehog.geo.threed.curves.Ray3D
public class Ray3D
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
| 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.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 |
|---|
protected Point3D mOrigin
protected Vector3D mDirection
| Constructor Detail |
|---|
public Ray3D()
public Ray3D(Point3D origin,
Vector3D direction)
throws java.lang.IllegalArgumentException
origin - Ray origin.direction - Ray direction.
java.lang.IllegalArgumentException - Thrown if origin or direction are null or if direction is not of unit length.
public Ray3D(Point3D origin,
Vector3D direction,
java.lang.String name,
ID id)
throws java.lang.IllegalArgumentException
origin - Ray origin.direction - Ray direction.name - Object name.id - Object ID.
java.lang.IllegalArgumentException - Thrown if origin or direction are null or if direction is not of unit length.
public Ray3D(Point3D origin,
Point3D otherPoint)
throws java.lang.IllegalArgumentException
origin - Ray origin.otherPoint - Othe point from which to compute ray direction.
java.lang.IllegalArgumentException - Thrown if origin or otherPoint are null. or if origin to otherPoint are the same point within hedgehog.utility.Tolerances.TOLERANCE.public Ray3D(java.lang.String name)
name - Ray name.public Ray3D(ID id)
id - Ray ID.
public Ray3D(java.lang.String name,
ID id)
name - Ray name.id - Ray ID.public Ray3D(Ray3D object)
object - Object to copy.| Method Detail |
|---|
public Point3D getOrigin()
public Vector3D getDirection()
public void setOrigin(Point3D origin)
origin - New ray origin.public void setDirection(Vector3D direction)
direction - new ray direction.
java.lang.IllegalArgumentException - Thrown if the specified direction vector is null or not of unit length.public Curve3D copy()
copy in class HObject
public Point3D intermediatePoint(double c1,
double c2)
throws java.lang.IllegalArgumentException
c1 - Numerator value.c2 - Denomiator value.
java.lang.IllegalArgumentException - Thrown if ||c1+c2||
public void intermediatePoint(Point3D p,
HDouble c1,
HDouble c2)
throws java.lang.IllegalArgumentException
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.
java.lang.IllegalArgumentException - Thrown if p does not lie on this ray.
public Point3D intersection(Ray3D ray,
double tolerance)
ray - Other ray to test for intersection.tolerance - Required tolerance.
public boolean isSelfIntersecting()
public boolean isValid()
public boolean isParallelToXAxis(double tolerance)
tolerance - Required tolerance.
public boolean isParallelToYAxis(double tolerance)
tolerance - Required tolerance.
public boolean isParallelToZAxis(double tolerance)
tolerance - Required tolerance.
public void lengthCoordinates(Point3D p,
HDouble zeta1,
HDouble zeta2)
throws java.lang.IllegalArgumentException
p - Point to determine length coordinates.zeta1 - Set upon return to length coordinate 1.zeta2 - Set upon return to length coordinate 2.
java.lang.IllegalArgumentException - Thrown if p not on this ray.public Ray3D toLocalCoordinateSystem(OrthogonalCoordinateSystem3D ocs)
ocs - Coordinate system.
public double length()
length in class Curve3D
public double minimumDistance(Point3D p,
double tolerance)
minimumDistance in class Curve3Dp - Point.tolerance - Required tolerance.
public double distanceToSquared(Point3D p)
p - Point.
public double distanceTo(Point3D p)
p - Point.
public void normaliseDirectionVector()
public double distanceToSquared(Ray3D ray1,
double tolerance,
Point3D ray0ClosestPoint,
Point3D ray1ClosestPoint)
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.
public double distanceTo(Ray3D ray1,
double tolerance,
Point3D ray0ClosestPoint,
Point3D ray1ClosestPoint)
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.
public Point3D midPoint()
midPoint in class Curve3D
public double parametricVariable(Point3D p,
double tolerance)
throws java.lang.IllegalArgumentException
parametricVariable in class Curve3Dp - Point to determine parametric variable value.tolerance - Required tolerance.
java.lang.IllegalArgumentException - Thrown if p is not on this ray.
public java.util.ArrayList<Point3D> pointsOnRay(Point3D startPoint,
Point3D endPoint,
double distanceBetweenPoints)
throws java.lang.IllegalArgumentException
startPoint - Strat point.endPoint - End point.distanceBetweenPoints - Distance between intermediate points.
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.
public boolean pointOfCurve(Point3D p,
double tolerance)
pointOfCurve in class Curve3Dp - Point to test.tolerance - Required tolerance.
public boolean pointOnCurve(Point3D p,
double tolerance)
pointOnCurve in class Curve3Dp - Point to test.tolerance - Required tolerance.
public Point3D pointOnCurve(double t,
double tolerance)
throws java.lang.IllegalArgumentException
pointOnCurve in class Curve3Dt - 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.
java.lang.IllegalArgumentException - Thrown if invalid t.
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.
pset - Point set.
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.public Point3D projectPointOntoRay(Point3D p)
p - Point to project.
public void reverse()
reverse in class Curve3D
public Curve3D scale(double s,
Point3D fixedPoint)
scale in class Curve3Ds - Scaling factor.fixedPoint - Fixed point about which scaling occurs. If null then scaling is with respect to the global origin.
public Curve3D rotate(double theta,
double beta,
double gamma,
Point3D fixedPoint,
boolean degrees)
throws java.lang.IllegalArgumentException
rotate in class Curve3Dtheta - 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.
java.lang.IllegalArgumentException - Thrown if invalid angles specified.
public Vector3D secondDerivative(double u)
throws java.lang.IllegalArgumentException
secondDerivative in class Curve3Du - Parametric-variable value on this ray.
java.lang.IllegalArgumentException - Thrown if u is out of range [0:infinity].public java.lang.String toString()
toString in class Curve3D
public Vector3D tangent(double u)
throws java.lang.IllegalArgumentException
tangent in class Curve3Du - Parametric-variable value.
java.lang.IllegalArgumentException - Thrown if u is out of range [0:infinity].public Vector3D tangent(Point3D p)
tangent in class Curve3Dp - Point on ray.
public double torsion(double u)
throws java.lang.IllegalArgumentException
torsion in class Curve3Du - Parametric-variable value.
java.lang.IllegalArgumentException - Thrown if u is out of range [0:infinity].
public Curve3D translate(double tx,
double ty,
double tz)
translate in class Curve3Dtx - Translation in x-direction.ty - Translation in y-direction.tz - Translation in z-direction.
public java.util.Vector<ModelObject> childModelObjects()
childModelObjects in interface ModelObject
public java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection,
int modelID)
throws java.sql.SQLException
databaseInsertStatement in interface ModelObjectconnection - Database connection.modelID - Model ID.
java.sql.SQLException - Thrown if an SQL exception occurs.
public java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection,
int modelID)
throws java.sql.SQLException
databaseUpdateStatement in interface ModelObjectconnection - Database connection.modelID - Model ID.
java.sql.SQLException - Thrown if an SQL exception occurs.
public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Element doucmentRootNode)
throws InvalidObjectException
toXMLNode in interface ModelObjectdocument - XML document.doucmentRootNode - Doucmnet root node.
InvalidObjectException - Thrown if this object's ID is equal to the default ID of -1.
public ModelObject fromXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Node documentRootNode,
org.w3c.dom.Node node,
Model model)
throws InvalidObjectException
fromXMLNode in interface ModelObjectdocument - XML document.documentRootNode - Document root node; ie Model node.node - XML node.model - The model to which this object is added.
InvalidObjectException - Thrown if an error occurred building the object.
public ModelObject fromDatabase(java.sql.Connection connection,
Model model,
int modelID,
int objectID)
throws java.sql.SQLException
fromDatabase in interface ModelObjectconnection - Database connection.modelID - Model ID.objectID - Object ID in associated ModelObjects table.model - Model built from database.
java.sql.SQLException - Thrown if an SQL exception occurs.
public X3DNode toX3DNode(X3DObject x3dObject)
throws InvalidObjectException
toX3DNode in interface ModelObjectx3dObject - X3D object.
InvalidObjectException - Thrown if this object is invalid.public void transform(Matrix4x4 matrix)
transform in class Curve3Dmatrix - Transformation matrix.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||