Package toxi.geom

Class LineStrip2D

java.lang.Object
toxi.geom.LineStrip2D
All Implemented Interfaces:
Iterable<Vec2D>

public class LineStrip2D extends Object implements Iterable<Vec2D>
  • Constructor Details

    • LineStrip2D

      public LineStrip2D()
    • LineStrip2D

      public LineStrip2D(Collection<? extends Vec2D> vertices)
  • Method Details

    • add

      public LineStrip2D add(float x, float y)
    • add

      public LineStrip2D add(ReadonlyVec2D p)
    • add

      public LineStrip2D add(Vec2D p)
    • get

      public Vec2D get(int i)
      Returns the vertex at the given index. This function follows Python convention, in that if the index is negative, it is considered relative to the list end. Therefore the vertex at index -1 is the last vertex in the list.
      Parameters:
      i - index
      Returns:
      vertex
    • getBoundingCircle

      public Circle getBoundingCircle()
    • getBounds

      public Rect getBounds()
    • getCentroid

      public Vec2D getCentroid()
    • getDecimatedVertices

      public List<Vec2D> getDecimatedVertices(float step)
      Computes a list of points along the spline which are uniformly separated by the given step distance.
      Parameters:
      step -
      Returns:
      point list
    • getDecimatedVertices

      public List<Vec2D> getDecimatedVertices(float step, boolean doAddFinalVertex)
      Computes a list of points along the spline which are close to uniformly separated by the given step distance. The uniform distribution is only an approximation and is based on the estimated arc length of the polyline. The distance between returned points might vary in places, especially if there're sharp angles between line segments.
      Parameters:
      step -
      doAddFinalVertex - true, if the last vertex computed should be added regardless of its distance.
      Returns:
      point list
    • getEdges

      public List<Line2D> getEdges()
      Returns a list of Line2D segments representing the segments between the vertices of this strip.
      Returns:
      list of lines
    • getLength

      public float getLength()
    • getPointAt

      public Vec2D getPointAt(float t)
      Computes point at position t, where t is the normalized position along the strip. If t<0 then the first vertex of the strip is returned. If t>=1.0 the last vertex is returned. If the strip contains less than 2 vertices, this method returns null.
      Parameters:
      t -
      Returns:
    • getSegments

      public List<Line2D> getSegments()
    • getVertices

      public List<Vec2D> getVertices()
      Returns:
      the vertices
    • intersectLine

      public Line2D.LineIntersection intersectLine(Line2D line)
    • iterator

      public Iterator<Vec2D> iterator()
      Specified by:
      iterator in interface Iterable<Vec2D>
    • rotate

      public LineStrip2D rotate(float theta)
    • scale

      public LineStrip2D scale(float scale)
    • scale

      public LineStrip2D scale(float x, float y)
    • scale

      public LineStrip2D scale(ReadonlyVec2D scale)
    • scaleSize

      public LineStrip2D scaleSize(float scale)
    • scaleSize

      public LineStrip2D scaleSize(float x, float y)
    • scaleSize

      public LineStrip2D scaleSize(ReadonlyVec2D scale)
    • setVertices

      public void setVertices(List<Vec2D> vertices)
      Parameters:
      vertices - the vertices to set
    • translate

      public LineStrip2D translate(float x, float y)
    • translate

      public LineStrip2D translate(ReadonlyVec2D offset)