Class Path3D

java.lang.Object
org.bzdev.geom.Path3D
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
Path3D.Double, Path3D.Float

public abstract class Path3D extends Object implements Cloneable
Class implementing paths in a three-dimensional Euclidean space. The API is similar to that for 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
    Modifier and Type
    Class
    Description
    static class 
    Class extending Path3D by storing coordinate data as double-precision numbers.
    static class 
    Class extending Path3D by storing coordinate data as single-precision numbers.
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    append(Path3D path, boolean connect)
    Append the path segments specified by another path.
    abstract void
    append(PathIterator3D pi, boolean connect)
    Append the path segments specified by a path iterator.
     
    final void
    Close a path.
    abstract Path3D
    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
    /** Get the last point on a path.
    Get a path iterator for this path.
    abstract Point3D
    Get the starting point of a path.
    boolean
    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 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[]
    Compute the array representing the control points for a cubic Bézier curve that represents a straight segment line between two points.
    static double[]
    Compute the array representing the control points for a cubic Bézier curve that matches a quadratic Bézier curve.
    abstract void
    Apply a transform to a path.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public abstract void append(PathIterator3D pi, boolean connect)
      Append the path segments specified by a path iterator.
      Parameters:
      pi - the path iterator
      connect - true if an initial MOVETO segment obtained from the path iterator should be turned into a LINETO segment
    • append

      public final void append(Path3D path, boolean connect)
      Append the path segments specified by another path.
      Parameters:
      path - the other path
      connect - true if an initial MOVETO segment obtained from the other path should be turned into a LINETO segment
    • getBounds

      public Rectangle3D 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

      public final Point3D 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

      public abstract PathIterator3D getPathIterator(Transform3D tform)
      Get a path iterator for this path. The iterator will ignore new segments added after the call to this method, but reset() 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

      public abstract Path3D createTransformedPath(Transform3D transform)
      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 point
      y1 - the Y coordinate of the first control point
      z1 - the Z coordinate of the first control point
      x2 - the X coordinate of the second control point
      y2 - the Y coordinate of the second control point
      z2 - the Z coordinate of the second control point
      x3 - the X coordinate of the final point of the segment
      y3 - the Y coordinate of the final point of the segment
      z3 - 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 point
      y - the Y coordinate of the segment's end point
      z - 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 point
      y - the Y coordinate of the new current point
      z - 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 point
      y1 - the Y coordinate of the control point
      z1 - the Z coordinate of the control point
      x2 - the X coordinate of the end point of the segment
      y2 - the Y coordinate of the end point of the segment
      z2 - the Z coordinate of the end point of the segment
    • transform

      public abstract void transform(Transform3D tform)
      Apply a transform to a path. The transform will be applied to each segment's control points.
      Parameters:
      tform - the transform
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • getStart

      public abstract Point3D getStart()
      Get the starting point of a path.
      Returns:
      the first point along the path; null if the path is empty
    • getEnd

      public abstract Point3D getEnd()
      /** Get the last point on a path.
      Returns:
      the last point; null if the path is empty or closed at its end
    • setupCubic

      public 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. 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 segment
      p2 - 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

      public 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. 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 curve
      p2 - the control point of the quadratic Bézier curve between the start and end points
      p3 - 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 segment
      y0 - the Y coordinate of the point at the start of the line segment
      z0 - the Z coordinate of the point at the start of the line segment
      x3 - the X coordinate of the point at the end of the line segment
      y3 - the Y coordinate of the point at the end of the line segment
      z3 - 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 segment
      y0 - the Y coordinate of the point at the start of the line segment
      z0 - the Z coordinate of the point at the start of the line segment
      xc - the X coordinate of the intermediate control point
      yc - the Y coordinate of the intermediate control point
      zc - the Z coordinate of the intermediate control point
      x3 - the X coordinate of the point at the end of the line segment
      y3 - the Y coordinate of the point at the end of the line segment
      z3 - 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.