toxi.geom
Class Line2D

java.lang.Object
  extended by toxi.geom.Line2D

public class Line2D
extends java.lang.Object


Nested Class Summary
static class Line2D.LineIntersection
           
 
Field Summary
 Vec2D a
           
 Vec2D b
           
 
Constructor Summary
Line2D(Vec2D a, Vec2D b)
           
 
Method Summary
 Line2D copy()
           
 Vec2D getDirection()
           
 float getLength()
           
 Vec2D getMidPoint()
           
 Vec2D getNormal()
           
 Line2D.LineIntersection intersectLine(Line2D l)
          Computes intersection between this and the given line.
 java.util.ArrayList<Vec2D> splitIntoSegments(java.util.ArrayList<Vec2D> segments, float stepLength, boolean addFirst)
           
static java.util.ArrayList<Vec2D> splitIntoSegments(Vec2D a, Vec2D b, float stepLength, java.util.ArrayList<Vec2D> segments, boolean addFirst)
          Splits the line between A and B into segments of the given length, starting at point A.
 Ray2D toRay2D()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

public Vec2D a

b

public Vec2D b
Constructor Detail

Line2D

public Line2D(Vec2D a,
              Vec2D b)
Method Detail

copy

public Line2D copy()

getDirection

public Vec2D getDirection()

getLength

public float getLength()

getMidPoint

public Vec2D getMidPoint()

getNormal

public Vec2D getNormal()

intersectLine

public Line2D.LineIntersection intersectLine(Line2D l)
Computes intersection between this and the given line. The returned value is a Line2D.LineIntersection instance and contains both the type of intersection as well as the intersection point (if existing). Based on: http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/

Parameters:
l - line to intersect with
Returns:
intersection result

splitIntoSegments

public java.util.ArrayList<Vec2D> splitIntoSegments(java.util.ArrayList<Vec2D> segments,
                                                    float stepLength,
                                                    boolean addFirst)

toRay2D

public Ray2D toRay2D()

splitIntoSegments

public static final java.util.ArrayList<Vec2D> splitIntoSegments(Vec2D a,
                                                                 Vec2D b,
                                                                 float stepLength,
                                                                 java.util.ArrayList<Vec2D> segments,
                                                                 boolean addFirst)
Splits the line between A and B into segments of the given length, starting at point A. The tweened points are added to the given result list. The last point added is B itself and hence it is likely that the last segment has a shorter length than the step length requested. The first point (A) can be omitted and not be added to the list if so desired.

Parameters:
a - start point
b - end point (always added to results)
stepLength - desired distance between points
segments - existing array list for results (or a new list, if null)
addFirst - false, if A is NOT to be added to results
Returns:
list of result vectors