java.lang.Object
org.bzdev.geom.Path2DInfo.SegmentData
- Enclosing class:
- Path2DInfo
Class to store values used in computations on a segment of
a path.
-
Constructor Summary
ConstructorsConstructorDescriptionSegmentData(int st, double x0, double y0, double[] coords, Path2DInfo.SegmentData last) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiondoubleCompute the signed curvature at a point with a given path parameter If the 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.booleanDetermine if the curvature exists for the specified argument.doubleCompute the second derivative with respect to the path parameter of the signed distance along the path from its initial pointdoubleCompute the second derivative with respect to the path parameter of the X coordinate of a point on the path.doubleCompute the second derivative with respect to the path parameter of the Y coordinate of a point on the path.doubleCompute the third derivative with respect to the path parameter of the X coordinate of a point on the path.doubleCompute the third derivative with respect to the path parameter of the Y coordinate of a point on the path.doubleCompute the derivative with respect to the path parameter of the signed distance along the path from its initial pointdoubleCompute the derivative with respect to the path parameter of the X coordinate of a point on the path.doubleCompute the derivative with respect to the path parameter of the Y coordinate of a point on the path.booleangetNormal(Path2DInfo.UValues uv, double[] array, int offset) Get the normal vector for a given value of the path parameter and an offset for the array storing the normal vector.booleangetTangent(Path2DInfo.UValues uv, double[] array, int offset) Get the tangent vector for a specified value of the path parameter and an output-array offset.intgetType()Get the type for this segmentdoubleCompute the X coordinate of a point on the path.doubleCompute the X coordinate of a point on the path.
-
Constructor Details
-
SegmentData
public SegmentData(int st, double x0, double y0, double[] coords, Path2DInfo.SegmentData last) throws IllegalArgumentException Constructor.- Parameters:
st- the path-segment type, legal values of which arex0- the initial x coordinate for the segment (ignored for thePathIterator.SEG_MOVETOcase)y0- the initial y coordinate for the segment (ignored for thePathIterator.SEG_MOVETOcase)coords- the coordinates array set by a call toPathIterator.currentSegment(double[]), but with the first three elements set to the x and coordinates respectively for the previousPathIterator.SEG_MOVETOsegment when first argument's value isPathIterator.SEG_CLOSE. The size of this array should be at least 2 and the maximum size needed is 6.last- the previous SegmentData for a path; null if there is none- Throws:
IllegalArgumentException- a value was out of rangeArrayIndexOutOfBoundsException- the array argument was two smallNullPointerException- the array argument was null- See Also:
-
-
Method Details
-
getX
Compute the X coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the X coordinate
-
getY
Compute the X coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the Y coordinate
-
dxDu
Compute the derivative with respect to the path parameter of the X coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the derivative of the X coordinate with respect to the path parameter
-
dyDu
Compute the derivative with respect to the path parameter of the Y coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the derivative of the Y coordinate with respect to the path parameter
-
d2xDu2
Compute the second derivative with respect to the path parameter of the X coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the second derivative of the X coordinate with respect to the path parameter
-
d3xDu3
Compute the third derivative with respect to the path parameter of the X coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the third derivative of the X coordinate with respect to the path parameter
-
d3yDu3
Compute the third derivative with respect to the path parameter of the Y coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the third derivative of the X coordinate with respect to the path parameter
-
d2yDu2
Compute the second derivative with respect to the path parameter of the Y coordinate of a point on the path.- Parameters:
uv- the path parameter- Returns:
- the second derivative of the Y coordinate with respect to the path parameter
-
dsDu
Compute the derivative with respect to the path parameter of the signed distance along the path from its initial point- Parameters:
uv- the path parameter- Returns:
- the derivative of the signed distance along the path with respect to the path parameter
-
d2sDu2
Compute the second derivative with respect to the path parameter of the signed distance along the path from its initial point- Parameters:
uv- the path parameter- Returns:
- the second derivative of the signed distance along the path with respect to the path parameter
-
curvature
Compute the signed curvature at a point with a given path parameter If the 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.- Parameters:
uv- the path parameter- Returns:
- the curvature (Double.NaN if not defined) with positive values indicating that the tangent vector rotates counterclockwise as the path parameter increases
-
curvatureExists
Determine if the curvature exists for the specified argument. 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).- Parameters:
uv- the path parameter- Returns:
- true if the curvature exists; false otherwise
-
getType
public int getType()Get the type for this segment- Returns:
- the type of this segment, legal values of which
are
PathIterator.SEG_MOVETO,PathIterator.SEG_LINETO,PathIterator.SEG_QUADTO,PathIterator.SEG_CUBICTO, andPathIterator.SEG_CLOSE.
-
getTangent
Get the tangent vector for a specified value of the path parameter and an output-array offset. 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:
uv- the path parameterarray- 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
-
getNormal
Get the normal vector for a given value of the path parameter and an offset for the array storing the normal vector. 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:
uv- the path parameterarray- 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
-