Package snap.geom

Class Segment

Direct Known Subclasses:
Cubic, Line, Quad

public abstract class Segment extends Shape
A Segment is a Shape subclass that represents a part of a path: line, quadratic, cubic.
  • Field Details

    • x0

      public double x0
    • y0

      public double y0
    • x1

      public double x1
    • y1

      public double y1
  • Constructor Details

    • Segment

      public Segment()
  • Method Details

    • getX0

      public double getX0()
      Returns the first point x.
    • getY0

      public double getY0()
      Returns the first point y.
    • getX1

      public double getX1()
      Returns the second point x.
    • getY1

      public double getY1()
      Returns the second point y.
    • getPoints

      public Point[] getPoints()
      Returns the points.
    • getEndCoords

      public double[] getEndCoords(double[] coords)
      Returns the point coords.
    • getX

      public abstract double getX(double aLoc)
      Returns the x value at given parametric location.
    • getY

      public abstract double getY(double aLoc)
      Returns the y value at given parametric location.
    • getArcLength

      public double getArcLength()
      Returns the length of this segment.
      Overrides:
      getArcLength in class Shape
    • getArcLengthImpl

      protected abstract double getArcLengthImpl()
      Calculates and returns length of this segment.
    • split

      public abstract Segment split(double aLoc)
      Splits the segement at given parametric location and return the remainder.
    • createReverse

      public abstract Segment createReverse()
      Creates and returns the reverse of this segement.
    • matches

      public abstract boolean matches(Object anObj)
      Returns whether segement is equal to another, regardless of direction.
    • containsSeg

      public boolean containsSeg(Segment aSeg)
      Override to return false (segment can never contain another segment (well, I suppose a weird Cubic could)).
      Overrides:
      containsSeg in class Shape
    • intersectsSeg

      public boolean intersectsSeg(Segment aSeg)
      Returns whether this segment intersects given segment.
      Overrides:
      intersectsSeg in class Shape
    • crossesSeg

      public boolean crossesSeg(Segment aSeg)
      Returns whether this segment intersects given segment.
      Overrides:
      crossesSeg in class Shape
    • getHit

      public SegHit getHit(Segment aSeg)
      Returns the hit for given segment.
    • getHitPoint

      public double getHitPoint(Segment aSeg)
      Returns the hit for given segment.
    • getPointAndAngle

      public double getPointAndAngle(double t, Point aPoint)
      Like getPoint(), but also returns angle of tangent at point t (in degrees). calculated point along curve is stored in aPoint
    • equals

      public static final boolean equals(double v1, double v2)
      Returns whether double values are equal to nearest tenth of pixel.
    • newSegmentForSegAndPoints

      public static Segment newSegmentForSegAndPoints(Seg aSeg, double[] coords)
      Creates a Segment for given Seg and points.