java.lang.Object
org.bzdev.geom.BasicSplinePath2D.Location
- Enclosing class:
- BasicSplinePath2D
Class representing a location along a path that is an instance
of BasicSplinePath2D.
A location is associated with a position along a path - a
particular value of the path parameter - and stores data
that allows various quantities to be computed with higher
efficiency than would otherwise be possible. It is useful
for the case where multiple quantities will be computed
for the same location.
-
Method Summary
Modifier and TypeMethodDescriptiondouble
Compute the signed curvature at the point along the path corresponding to this location.boolean
Determine if the curvature exists at the point along the path corresponding to this location.double
d2sDu2()
Compute the second derivative with respect to the path parameter of the signed distance along the path from its initial point.double
d2xDu2()
Compute the second derivative with respect to the path parameter of the X coordinate, evaluated at the point along the path corresponding to this location.double
d2yDu2()
Compute the second derivative with respect to the path parameter of the Y coordinate, evaluated at the point along the path corresponding to this location.double
dsDu()
Compute the derivative with respect to the path parameter of the signed distance along the path from its initial point.double
dxDu()
Compute the derivative with respect to the path parameter of the X coordinate for the point along the path corresponding to this location.double
dyDu()
Compute the derivative with respect to the path parameter of the Y coordinate for the point along the path corresponding to this location.boolean
getNormal
(double[] array, int offset) Get the normal vector for the point along the path corresponding to this location.double
Get the path parameter corresponding to this location along the path.getPoint()
Get the point along the path corresponding to this location.boolean
getTangent
(double[] array, int offset) Get the tangent vector for the point along the path corresponding to this location.double
getX()
Get the X coordinate of the point along the path corresponding to this location.double
getY()
Get the Y coordinate of the point along the path corresponding to this location.
-
Method Details
-
getPathParameter
public double getPathParameter()Get the path parameter corresponding to this location along the path.- Returns:
- the path parameter
-
getPoint
Get the point along the path corresponding to this location.- Returns:
- the point along the path
- Throws:
IllegalStateException
- this location is no longer valid
-
getX
public double getX()Get the X coordinate of the point along the path corresponding to this location.- Returns:
- the X coordinate
- Throws:
IllegalStateException
- this location is no longer valid
-
getY
public double getY()Get the Y coordinate of the point along the path corresponding to this location.- Returns:
- the Y coordinate
- Throws:
IllegalStateException
- this location is no longer valid
-
dxDu
public double dxDu()Compute the derivative with respect to the path parameter of the X coordinate for the point along the path corresponding to this location.- Returns:
- the derivative of the X coordinate with respect to the path parameter
- Throws:
IllegalStateException
- this location is no longer valid
-
dyDu
public double dyDu()Compute the derivative with respect to the path parameter of the Y coordinate for the point along the path corresponding to this location.- Returns:
- the derivative of the Y coordinate with respect to the path parameter
- Throws:
IllegalStateException
- this location is no longer valid
-
d2xDu2
public double d2xDu2()Compute the second derivative with respect to the path parameter of the X coordinate, evaluated at the point along the path corresponding to this location.- Returns:
- the second derivative of the X coordinate with respect to the path parameter
- Throws:
IllegalStateException
- this location is no longer valid
-
d2yDu2
public double d2yDu2()Compute the second derivative with respect to the path parameter of the Y coordinate, evaluated at the point along the path corresponding to this location.- Returns:
- the second derivative of the Y coordinate with respect to the path parameter
- Throws:
IllegalStateException
- this location is no longer valid
-
dsDu
public double dsDu()Compute the derivative with respect to the path parameter of the signed distance along the path from its initial point. The derivative is evaluated at the point along the path corresponding to this location.- Returns:
- the derivative of the signed distance along the path with respect to the path parameter
- Throws:
IllegalStateException
- this location is no longer valid
-
d2sDu2
public double d2sDu2()Compute the second derivative with respect to the path parameter of the signed distance along the path from its initial point. The derivative is evaluated at the point along the path corresponding to this location.- Returns:
- the second derivative of the signed distance along the path with respect to the path parameter
- Throws:
IllegalStateException
- this location is no longer valid
-
curvature
public double curvature()Compute the signed curvature at the point along the path corresponding to this location. If the current path segment's type isPathIterator.SEG_CLOSE
, the starting and ending points of the segment are identical, and the path parameter corresponding to the argument is zero, the curvature at the end of the previous segment is returned. A positive curvature corresponds to a rotation from the positive X axis towards the positive Y axis for an angular distance of 90 degrees. Similarly a negative curvature corresponds to a rotation from the positive Y axis towards the positive X axis for an angular distance of 90 degrees.- Returns:
- the curvature (Double.NaN if not defined) with positive values indicating that the tangent vector rotates counterclockwise as the path parameter increases
- Throws:
IllegalStateException
- this location is no longer valid
-
curvatureExists
public boolean curvatureExists()Determine if the curvature exists at the point along the path corresponding to this location. In general, the curvature does not exist when all the points along a segment are the same point or when the segment is a SEG_MOVETO segment (which just indicates the start of a curve). For a SEG_CLOSE segment where the starting and ending points are identical, the curvature exists if the curvature of the previous segment exists at its end (u = 1.0).- Returns:
- true if the curvature exists; false otherwise
- Throws:
IllegalStateException
- this location is no longer valid
-
getTangent
public boolean getTangent(double[] array, int offset) Get the tangent vector for the point along the path corresponding to this location. If the tangent vector does not exist (e.g., the length of the line does not vary with the path parameter), the tangent vector will be set to zero. The tangent vector will have unit length if it is not zero.- Parameters:
array
- an array of length no less than 2 used to store the tangent vector, with array[offset] containing the tangent vector's X component and array[offset+1] containing the tangent vector's Y componentoffset
- the index into the array at which to store the tangent vector- Returns:
- true if the tangent vector exists; false if the tangent vector does not exist
- Throws:
IllegalStateException
- this location is no longer valid
-
getNormal
public boolean getNormal(double[] array, int offset) Get the normal vector for the point along the path corresponding to this location. The normal vector N is a vector of unit length, perpendicular to the tangent vector, and oriented so that d2r/ds2 = κN where κ is the (signed) curvature. If the normal vector does not exist (e.g., the length of the line does not vary with the path parameter), the normal vector will be set to zero.Note: the use of the signed curvature results in the normal vector always pointing in the counter-clockwise direction (i.e., a rotating the X axis towards the Y axis). This allows a normal vector exist for straight-line segments. A different definition is used for 3D paths.
- Parameters:
array
- an array of length no less than 2 used to store the normal vector, with array[offset] containing the normal vector's X component and array[offset+1] containing the normal vector's Y componentoffset
- the index into the array at which to store the normal vector- Returns:
- true if the normal vector exists; false if the normal vector does not exist
- Throws:
IllegalStateException
- this location is no longer valid
-