- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
Path3D.Double
,Path3D.Float
Path2D
as
users are likely to be familiar with that class.
Implementation note: all the subclasses of this class must be in the package org.bzdev.geom.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Append the path segments specified by another path.abstract void
append
(PathIterator3D pi, boolean connect) Append the path segments specified by a path iterator.clone()
final void
Close a path.abstract Path3D
createTransformedPath
(Transform3D transform) Create a new path by applying a transform to this path.abstract void
curveTo
(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3) Add a segment specified by a cubic Bézier curve.Get a bounding rectangle that encloses all of the points of this path.final Point3D
Get the current point.abstract Point3D
getEnd()
/** Get the last point on a path.abstract PathIterator3D
getPathIterator
(Transform3D tform) Get a path iterator for this path.abstract Point3D
getStart()
Get the starting point of a path.boolean
isEmpty()
Determine if this path is empty.abstract void
lineTo
(double x, double y, double z) Add a straight-line segment starting from the current point.abstract void
moveTo
(double x, double y, double z) Move the current point to a new location or to an initial location.abstract void
quadTo
(double x1, double y1, double z1, double x2, double y2, double z2) Add a segment specified by a quadratic Bézier curve.final void
reset()
Reset the path by removing all of its segments.static double[]
setupCubic
(double x0, double y0, double z0, double x3, double y3, double z3) Compute the array representing the control points for a cubic Bézier curve that represents a straight segment line between two points represented by their X, Y, Z, coordinates.static double[]
setupCubic
(double x0, double y0, double z0, double xc, double yc, double zc, double x3, double y3, double z3) Compute the array representing the control points for a cubic Bézier curve that matches a quadratic Bézier curve.static double[]
setupCubic
(Point3D p1, Point3D p2) Compute the array representing the control points for a cubic Bézier curve that represents a straight segment line between two points.static double[]
setupCubic
(Point3D p1, Point3D p2, Point3D p3) Compute the array representing the control points for a cubic Bézier curve that matches a quadratic Bézier curve.abstract void
transform
(Transform3D tform) Apply a transform to a path.
-
Method Details
-
isEmpty
public boolean isEmpty()Determine if this path is empty. An empty path contains no path segments and does not have a bounding box.- Returns:
- true of the path is empty; false otherwise
-
append
Append the path segments specified by a path iterator.- Parameters:
pi
- the path iteratorconnect
- true if an initial MOVETO segment obtained from the path iterator should be turned into a LINETO segment
-
append
Append the path segments specified by another path.- Parameters:
path
- the other pathconnect
- true if an initial MOVETO segment obtained from the other path should be turned into a LINETO segment
-
getBounds
Get a bounding rectangle that encloses all of the points of this path.- Returns:
- a bounding rectangular cuboid; null if the path is empty
-
getCurrentPoint
Get the current point. The current point is the last point added by a path segment, or the point provided by the last MOVETO operation if the last segment was created by calling {#link #closePath()}.- Returns:
- the current point; null if the path is empty
-
getPathIterator
Get a path iterator for this path. The iterator will ignore new segments added after the call to this method, butreset()
should not be called while this path iterator is in use.- Parameters:
tform
- the transform to apply to control points; null if there is none- Returns:
- a path iterator for this path
-
reset
public final void reset()Reset the path by removing all of its segments. This method should not be called if a path iterator is in use. -
closePath
public final void closePath()Close a path. The new current point will be the point specified by the last MOVETO operation. -
createTransformedPath
Create a new path by applying a transform to this path.- Parameters:
transform
- the transform- Returns:
- the new path
-
curveTo
public abstract void curveTo(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3) Add a segment specified by a cubic Bézier curve.- Parameters:
x1
- the X coordinate of the first control pointy1
- the Y coordinate of the first control pointz1
- the Z coordinate of the first control pointx2
- the X coordinate of the second control pointy2
- the Y coordinate of the second control pointz2
- the Z coordinate of the second control pointx3
- the X coordinate of the final point of the segmenty3
- the Y coordinate of the final point of the segmentz3
- the Z coordinate of the final point of the segment
-
lineTo
public abstract void lineTo(double x, double y, double z) Add a straight-line segment starting from the current point.- Parameters:
x
- the X coordinate of the segment's end pointy
- the Y coordinate of the segment's end pointz
- the Z coordinate of the segment's end point
-
moveTo
public abstract void moveTo(double x, double y, double z) Move the current point to a new location or to an initial location.- Parameters:
x
- the X coordinate of the new current pointy
- the Y coordinate of the new current pointz
- the Z coordinate of the new current point
-
quadTo
public abstract void quadTo(double x1, double y1, double z1, double x2, double y2, double z2) Add a segment specified by a quadratic Bézier curve.- Parameters:
x1
- the X coordinate of the control pointy1
- the Y coordinate of the control pointz1
- the Z coordinate of the control pointx2
- the X coordinate of the end point of the segmenty2
- the Y coordinate of the end point of the segmentz2
- the Z coordinate of the end point of the segment
-
transform
Apply a transform to a path. The transform will be applied to each segment's control points.- Parameters:
tform
- the transform
-
clone
-
getStart
Get the starting point of a path.- Returns:
- the first point along the path; null if the path is empty
-
getEnd
/** Get the last point on a path.- Returns:
- the last point; null if the path is empty or closed at its end
-
setupCubic
Compute the array representing the control points for a cubic Bézier curve that represents a straight segment line between two points. The first three values of the array returned include the coordinates of p1, so those values should be ignored if the results are used with the curveTo method of Path3D.This method, or the variant whose arguments are X, Y, Z coordinate, should be used when adding a cubic-triangle segment to a Surface3D as the resulting control points will be in the right place for tests used to determine if surface is well-formed.
The array will contain four control points, starting with p1 and ending with p2.
- Parameters:
p1
- the point at the start of the line segmentp2
- the pint at the end of the line segment- Returns:
- the control points, with each control point's X, Y, and Z coordinates adjacent in the array and in X, Y, Z order.
-
setupCubic
Compute the array representing the control points for a cubic Bézier curve that matches a quadratic Bézier curve. The first three values of the array returned include the coordinates of p1, so those values should be ignored if the results are used with the curveTo method of Path3D.This method, or the variant whose arguments are X, Y, Z coordinate, should be used when adding a cubic-triangle segment to a Surface3D as the resulting control points will be in the right place for tests used to determine if surface is well-formed.
The array will contain four control points, starting with p1 and ending with p3.
- Parameters:
p1
- the point at the start of the quadratic Bézier curvep2
- the control point of the quadratic Bézier curve between the start and end pointsp3
- the pint at the end of the the quadratic Bézier curve- Returns:
- the control points, with each control point's X, Y, and Z coordinates adjacent in the array and in X, Y, Z order.
-
setupCubic
public static double[] setupCubic(double x0, double y0, double z0, double x3, double y3, double z3) Compute the array representing the control points for a cubic Bézier curve that represents a straight segment line between two points represented by their X, Y, Z, coordinates. The choice of control points results in the functions giving the X, Y, and Z coordinates linear functions of the path parameter.This method, or the variant whose arguments are instances of Point3D, should be used when adding a cubic-triangle segment to a Surface3D as the resulting control points will be in the right place for tests used to determine if surface is well-formed.
The array will contain four control points, starting with (x0, y, z0) and ending with (x3, y3, z3).
- Parameters:
x0
- the X coordinate of the point at the start of the line segmenty0
- the Y coordinate of the point at the start of the line segmentz0
- the Z coordinate of the point at the start of the line segmentx3
- the X coordinate of the point at the end of the line segmenty3
- the Y coordinate of the point at the end of the line segmentz3
- the Z coordinate of the point at the end of the line segment- Returns:
- the control points, with each control point's X, Y, and Z coordinates adjacent in the array and in X, Y, Z order.
-
setupCubic
public static double[] setupCubic(double x0, double y0, double z0, double xc, double yc, double zc, double x3, double y3, double z3) Compute the array representing the control points for a cubic Bézier curve that matches a quadratic Bézier curve. The choice of control points results in the functions giving the X, Y, and Z coordinates linear functions of the path parameter.This method, or the variant whose arguments are instances of Point3D, should be used when adding a cubic-triangle segment to a Surface3D as the resulting control points will be in the right place for tests used to determine if surface is well-formed.
The array will contain four control points, starting with (x0, y0, z0) and ending with (x3, y3, z3).
- Parameters:
x0
- the X coordinate of the point at the start of the line segmenty0
- the Y coordinate of the point at the start of the line segmentz0
- the Z coordinate of the point at the start of the line segmentxc
- the X coordinate of the intermediate control pointyc
- the Y coordinate of the intermediate control pointzc
- the Z coordinate of the intermediate control pointx3
- the X coordinate of the point at the end of the line segmenty3
- the Y coordinate of the point at the end of the line segmentz3
- the Z coordinate of the point at the end of the line segment- Returns:
- the control points, with each control point's X, Y, and Z coordinates adjacent in the array and in X, Y, Z order.
-