|
||||||||||
| 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.twod.GeometricObject2D
com.hedgehog.geo.twod.curves.Curve2D
com.hedgehog.geo.twod.curves.Ray2D
public class Ray2D
Title: Ray2D - represents a 2D ray.
Description: Represents a 2D 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 Ray2D encapsulates its own origin point, 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 Vector2D |
mDirection
Ray direction. |
protected Point2D |
mOrigin
Ray origin. |
| Fields inherited from class com.hedgehog.geo.twod.curves.Curve2D |
|---|
mp0, mp1 |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
Ray2D()
Default constructor. |
|
Ray2D(ID id)
Constructor. |
|
Ray2D(Point2D origin,
Point2D otherPoint)
Constructor. |
|
Ray2D(Point2D origin,
Vector2D direction)
Constructor. |
|
Ray2D(Point2D origin,
Vector2D direction,
java.lang.String name,
ID id)
Constructor. |
|
Ray2D(Ray2D object)
Copy constructor. |
|
Ray2D(java.lang.String name)
Constructor. |
|
Ray2D(java.lang.String name,
ID id)
Constructor. |
|
| Method Summary | |
|---|---|
java.util.Vector<ModelObject> |
childModelObjects()
Returns a vector of this object's child ModelObject objects. |
Ray2D |
copy()
Returns a copy of this Ray2D 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(Point2D p)
Returns the distance from the specified point to this ray; ie sqrt(distanceToSquared(p)). |
double |
distanceTo(Ray2D ray1,
double tolerance,
Point2D ray0ClosestPoint,
Point2D ray1ClosestPoint)
Returns the minimum distance between this ray (ray0) and the specified ray (ray1). |
double |
distanceToSquared(Point2D p)
Returns the distance squared from the specified point to this ray. |
double |
distanceToSquared(Ray2D ray1,
double tolerance,
Point2D ray0ClosestPoint,
Point2D 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. |
Vector2D |
getDirection()
Returns the direction. |
Point2D |
getOrigin()
Returns the origin. |
Point2D |
getP0()
Returns end-point p0; which is set to mOrigin. |
Point2D |
getP1()
Returns end-point p1; which is set to null to indicte that this ray does not have an end-point p1. |
Point2D |
intermediatePoint(double c1,
double c2)
Returns null since method is undefined for a ray of infinite length. |
void |
intermediatePointLengthCoordinates(Point2D p,
double tolerance,
HDouble c1,
HDouble c2)
Returns, via reference, the distances c1 and c2 from origin to p and p to end-of ray. |
Point2D |
intersection(Ray2D ray,
double tolerance)
Returns the point of intersection between two rays, if any. |
boolean |
isHorizontal(double tolerance)
Tests whether or not this ray is horizontal. |
boolean |
isSelfIntersecting()
Returns false since a ray cannot self-intersect. |
boolean |
isValid()
Tests the validity of this ray. |
boolean |
isVertical(double tolerance)
Tests whether or not this ray is vertical. |
double |
length()
Length of a ray is infinite, so hedgehog.utility.Tolerances.POSITIVE_INFINITE returned. |
void |
lengthCoordinates(Point2D p,
HDouble zeta1,
HDouble zeta2)
Sets both zeta1 and zeta2 to 0 since length coordinates are undefined because the ray length is infinite. |
Point2D |
midPoint()
Returns null since the mid-point of a ray is undefined. |
double |
minimumDistance(Point2D 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(Point2D p,
double tolerance)
Returns the value of the parametric variable, t, corresponding to the specified point. |
boolean |
pointOfCurve(Point2D p,
double tolerance)
Tests if the specified point is a point of this ray; ie if p is identical to the ray origin. |
Point2D |
pointOnCurve(double u,
double tolerance)
Returns a point on the ray given the parametric variable. |
boolean |
pointOnCurve(Point2D p,
double tolerance)
Tests whether or not the specified point is on this ray. |
boolean |
pointOnLeft(Point2D p,
double tolerance)
Tests whether or not the specified point is on the left of this ray. |
boolean |
pointOnRight(Point2D p,
double tolerance)
Tests whether or not the specified point is on the right of this ray. |
java.util.ArrayList<Point2D> |
pointsOnRay(Point2D startPoint,
Point2D endPoint,
double distanceBetweenPoints)
Returns a vector of points between the specified start and end points on this ray. |
static Ray2D |
rayThroughPointSet(Point2DSet pset)
Returns a Ray2D object that passes through the specified point set. |
void |
reverse()
Reverses the direction vector of this ray. |
Curve2D |
scale(double sx,
double sy,
Point2D fixedPoint)
Scales this ray by the specified scaling factors in the x and y directions. |
Vector2D |
secondDerivative(double u)
Returns the second derivative at u. |
void |
setDirection(Vector2D direction)
Sets the direction. |
void |
setOrigin(Point2D origin)
Sets the origin. |
Vector2D |
tangent()
Returns the tangent vector; ie the direction vector. |
Vector2D |
tangent(double u)
Returns the tangent vector; ie the ray direction vector. |
Vector2D |
tangent(Point2D p)
Returns the tangent vector; ie the ray direction vector. |
LinearLine2D |
toLinearLine2D()
Returns a LinearLine2D equivalent of this ray. |
double |
torsion(double u)
Returns the torsion at u. |
java.lang.String |
toString()
Returns a String representation of a Ray2D object. |
X3DNode |
toX3DNode(X3DObject x3dObject)
X3D support. |
org.w3c.dom.Element |
toXMLNode(org.w3c.dom.Document document,
org.w3c.dom.Element documentRootNode)
Returns the xml node of this object. |
Curve2D |
translate(double tx,
double ty)
Translates this ray by the specified (tx,ty) 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 Point2D mOrigin
protected Vector2D mDirection
| Constructor Detail |
|---|
public Ray2D()
public Ray2D(Point2D origin,
Vector2D direction)
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 Ray2D(Point2D origin,
Vector2D direction,
java.lang.String name,
ID id)
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 Ray2D(Point2D origin,
Point2D otherPoint)
throws java.lang.IllegalArgumentException
origin to otherPoint.
origin - Ray origin.otherPoint - Other point.
java.lang.IllegalArgumentException - Thrown if origin to otherPoint are the same point within hedgehog.utility.Tolerances.TOLERANCE.public Ray2D(java.lang.String name)
name - Object name.public Ray2D(ID id)
id - Object ID.
public Ray2D(java.lang.String name,
ID id)
name - Object name.id - Object ID.public Ray2D(Ray2D object)
object - Object to copy.| Method Detail |
|---|
public Point2D getOrigin()
public Vector2D getDirection()
public void setOrigin(Point2D origin)
origin - New origin.
public void setDirection(Vector2D direction)
throws java.lang.IllegalArgumentException
direction - New direction vector.
java.lang.IllegalArgumentException - Thrown if the specified direction vector is null or not of unit length.public Point2D getP0()
getP0 in class Curve2Dpublic Point2D getP1()
getP1 in class Curve2D
public Point2D pointOnCurve(double u,
double tolerance)
throws java.lang.IllegalArgumentException
pointOnCurve in class Curve2Du - Parametric distance along ray from ray origin.tolerance - Required tolerance used to test if the value of u is approximately 0 and hence at the ray origin.
java.lang.IllegalArgumentException - Thrown if u<0.
public boolean pointOnCurve(Point2D p,
double tolerance)
pointOnCurve in class Curve2Dp - Point to test.tolerance - Required tolerance.
public boolean pointOnLeft(Point2D p,
double tolerance)
pointOnLeft in class Curve2Dp - Point to test.tolerance - Required tolerance.
public boolean pointOnRight(Point2D p,
double tolerance)
pointOnRight in class Curve2Dp - Point to test.tolerance - Required tolerance.
public double length()
length in class Curve2Dpublic boolean isValid()
isValid in class Curve2Dpublic boolean isHorizontal(double tolerance)
tolerance - Required tolerance.
public boolean isVertical(double tolerance)
tolerance - Required tolerance.
public Ray2D copy()
copy in class HObjectpublic void reverse()
reverse in class Curve2Dpublic Point2D midPoint()
midPoint in class Curve2Dpublic boolean isSelfIntersecting()
public void lengthCoordinates(Point2D p,
HDouble zeta1,
HDouble zeta2)
p - Point at which to find length coordinates.zeta1 - Set upon return to length coordinate 1.zeta2 - Set upon return to length coordinate 2.
public double minimumDistance(Point2D p,
double tolerance)
minimumDistance in class Curve2Dp - Point from which to find minimum distance.tolerance - Required tolerance.
public double distanceToSquared(Point2D p)
p - Point.
public double distanceTo(Point2D p)
p - Point.
public void normaliseDirectionVector()
public double distanceToSquared(Ray2D ray1,
double tolerance,
Point2D ray0ClosestPoint,
Point2D 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(Ray2D ray1,
double tolerance,
Point2D ray0ClosestPoint,
Point2D 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 java.util.ArrayList<Point2D> pointsOnRay(Point2D startPoint,
Point2D endPoint,
double distanceBetweenPoints)
throws java.lang.IllegalArgumentException
startPoint - Start point. Must be on the ray and before the end point.endPoint - End point. Must be on the ray and after the start point.distanceBetweenPoints - Distance between intermediate points. Must be less than the dstance between the start and end 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 LinearLine2D toLinearLine2D()
public java.lang.String toString()
toString in class Curve2D
public boolean pointOfCurve(Point2D p,
double tolerance)
pointOfCurve in class Curve2Dp - Point to test.tolerance - Require tolerance.
public Vector2D tangent(double u)
throws java.lang.IllegalArgumentException
tangent in class Curve2Du - Parametric-variable along the ray from the origin.
java.lang.IllegalArgumentException - Thrown if u is invalid.
public Vector2D tangent(Point2D p)
throws java.lang.IllegalArgumentException
tangent in class Curve2Dp - Point at which to find the tangent.
java.lang.IllegalArgumentException - Thrown if p is invalid.public Vector2D tangent()
public double torsion(double u)
throws java.lang.IllegalArgumentException
u - Parametric-variable along the ray from the origin.
java.lang.IllegalArgumentException - Thrown if u is invalid.
public Curve2D translate(double tx,
double ty)
tx - Translation in the x-direction.ty - Translation in the y-direction.
public Curve2D scale(double sx,
double sy,
Point2D fixedPoint)
sx - Scaling in the x-direction.sy - Scaling in the y-direction.fixedPoint - Fixed point abut which scaling occurs. If set to null then scaling is wrt the global origin.
public Vector2D secondDerivative(double u)
throws java.lang.IllegalArgumentException
secondDerivative in class Curve2Du - Parametric-variable along the ray from the origin.
java.lang.IllegalArgumentException - Thrown if u is invalid.
public double parametricVariable(Point2D p,
double tolerance)
throws java.lang.IllegalArgumentException
parametricVariable in class Curve2Dp - Point from which to determine parametric variable equivalent.tolerance - Required tolerance.
java.lang.IllegalArgumentException - Thrown if p not on this ray.
public Point2D intersection(Ray2D ray,
double tolerance)
ray - Other ray to test for intersection.tolerance - Required tolerance.
public Point2D intermediatePoint(double c1,
double c2)
throws java.lang.IllegalArgumentException
c1 - Length coordinate c1, which is the distance between the origin and the required intermediate point.c2 - Length coordinate c2, which is the distance between the required point and the end of this ray.
java.lang.IllegalArgumentException - Thrown if (c1,c2) are invalid.
public void intermediatePointLengthCoordinates(Point2D p,
double tolerance,
HDouble c1,
HDouble c2)
throws java.lang.IllegalArgumentException
p - Point to determine distance from.tolerance - Required tolerance.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 static Ray2D rayThroughPointSet(Point2DSet pset)
throws java.lang.IllegalArgumentException,
InvalidObjectException
Returns a Ray2D 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 line then simply test the ray in both direcitons using Ray2D.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 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 documentRootNode)
throws InvalidObjectException
toXMLNode in interface ModelObjectdocument - XML document.documentRootNode - Document 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 the returned 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||