toxi.geom
Class Line2D
java.lang.Object
toxi.geom.Line2D
public class Line2D
- extends java.lang.Object
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
a
public Vec2D a
b
public Vec2D b
Line2D
public Line2D(Vec2D a,
Vec2D b)
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 pointb
- end point (always added to results)stepLength
- desired distance between pointssegments
- 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