Class Spiral2D

  • All Implemented Interfaces:
    Shape


    public class Spiral2D
    extends AbstractShape
    The Spiral2D class defines a spiral shape.

    This shape can be modeled by:
      centerX+coilGap*(t+coilOffset)*Math.cos(2*Math.PI*t*m+angularOffset);

      centerY+coilGap*(t+coilOffset)*Math.sin(2*Math.PI*t*m+angularOffset);

    See Also:
    Spiral2DPathIterator
    • Constructor Detail

      • Spiral2D

        public Spiral2D(double centerX,
                        double centerY,
                        double coilGap,
                        double coils,
                        double angularOffset,
                        double coilOffset,
                        boolean clockwise)
        Creates a new Spiral2D
        Parameters:
        centerX - the x-coordinate of the center of this spiral.
        centerY - the y-coordinate of the center of this spiral.
        coilGap - the space between any two coils.
        coils - the number of coils in this spiral.
        angularOffset - the angle at the center of this spiral.
        coilOffset - the space from the center of the spiral to where the path begins painting.
        clockwise - whether this spiral moves clockwise or counterclockwise from the center.
      • Spiral2D

        public Spiral2D(double centerX,
                        double centerY,
                        double coilGap,
                        double coils,
                        double angularOffset,
                        double coilOffset,
                        boolean clockwise,
                        boolean outward)
        Creates a new Spiral2D
        Parameters:
        centerX - the x-coordinate of the center of this spiral.
        centerY - the y-coordinate of the center of this spiral.
        coilGap - the space between any two coils.
        coils - the number of coils in this spiral.
        angularOffset - the angle at the center of this spiral.
        coilOffset - the space from the center of the spiral to where the path begins painting.
        clockwise - whether this spiral moves clockwise or counterclockwise from the center.
        outward - whether this spiral spins outward from the center, or inward toward the center. This argument only matters if you are going to study the PathIterator this shape produces.
    • Method Detail

      • createWithFixedCoilGap

        public static Spiral2D createWithFixedCoilGap(Point2D center,
                                                      Point2D end,
                                                      double coilGap)
        Creates a new Spiral2D with a center point, an end point, and a fixed gap between coils.
        Parameters:
        center - the center of this spiral.
        end - the outer tip of the spiral.
        coilGap - the gap between coils.
        Returns:
        a new Spiral2D
      • createWithFixedCoilGap

        public static Spiral2D createWithFixedCoilGap(double centerX,
                                                      double centerY,
                                                      double endX,
                                                      double endY,
                                                      double coilGap)
        Creates a new Spiral2D with a center point, an end point, and a fixed gap between coils.
        Parameters:
        centerX - the x-coordinate of the center of the spiral.
        centerY - the y-coordinate of the center of the spiral.
        endX - the x-coordinate of the outer tip of the spiral.
        endY - the y-coordinate of the outer tip of the spiral.
        coilGap - the gap between coils.
        Returns:
        a new Spiral2D
      • createWithFixedCoilCount

        public static Spiral2D createWithFixedCoilCount(Point2D center,
                                                        Point2D end,
                                                        double numCoils)
        Creates a new Spiral2D with a center point, an end point, and a fixed number of coils.
        Parameters:
        center - the center of the spiral.
        end - the outer tip of the spiral.
        numCoils - the number of coils in this spiral.
        Returns:
        a new Spiral2D
      • createWithFixedCoilCount

        public static Spiral2D createWithFixedCoilCount(double centerX,
                                                        double centerY,
                                                        double endX,
                                                        double endY,
                                                        double numCoils)
        Creates a new Spiral2D with a center point, an end point, and a fixed number of coils.
        Parameters:
        centerX - the x-coordinate of the center of the spiral.
        centerY - the y-coordinate of the center of the spiral.
        endX - the x-coordinate of the outer tip of the spiral.
        endY - the y-coordinate of the outer tip of the spiral.
        numCoils - the number of coils in the spiral.
        Returns:
        a new Spiral2D
      • setOutward

        public void setOutward(boolean b)
      • isOutward

        public boolean isOutward()
      • getCenterX

        public double getCenterX()
      • isClockwise

        public boolean isClockwise()
      • getCenterY

        public double getCenterY()
      • getCoilGap

        public double getCoilGap()
      • getCoils

        public double getCoils()
      • setAngularOffset

        public void setAngularOffset(double v)
      • getAngularOffset

        public double getAngularOffset()
      • setCoilOffset

        public void setCoilOffset(double v)
      • getCoilOffset

        public double getCoilOffset()
      • setClockwise

        public void setClockwise(boolean b)
      • setCenter

        public void setCenter(double centerX,
                              double centerY)
      • setCoilGap

        public void setCoilGap(double coilGap)
      • setCoils

        public void setCoils(double coils)
      • getWindingRule

        public int getWindingRule()