Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## toxi.geom
Class Line2D

    java.lang.Object
      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(ReadonlyVec2D a, ReadonlyVec2D b)`
`Line2D(Vec2D a, Vec2D b)`

Method Summary
`Vec2D` | `closestPointTo(ReadonlyVec2D p)` Computes the closest point on this line to the point given.
`Line2D` | `copy()`
`boolean` | `equals(java.lang.Object obj)`
`Vec2D` | `getDirection()`
`float` | `getLength()`
`float` | `getLengthSquared()`
`Vec2D` | `getMidPoint()`
`Vec2D` | `getNormal()`
`float` | `getTheta()`
`boolean` | `hasEndPoint(Vec2D p)`
`int` | `hashCode()`
`Line2D.LineIntersection` | `intersectLine(Line2D l)` Computes intersection between this and the given line.
`Line2D` | `offsetAndGrowBy(float offset, float scale, Vec2D ref)`
`Line2D` | `scale(float scale)`
`Line2D` | `set(Vec2D a, Vec2D b)`
`java.util.List<Vec2D>` | `splitIntoSegments(java.util.List<Vec2D> segments, float stepLength, boolean addFirst)`
`static java.util.List<Vec2D>` | `splitIntoSegments(Vec2D a, Vec2D b, float stepLength, java.util.List<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
`getClass, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### a

    public Vec2D a

### b

    public Vec2D b

Constructor Detail

### Line2D

    public Line2D(ReadonlyVec2D a,
                  ReadonlyVec2D b)

### Line2D

    public Line2D(Vec2D a,
                  Vec2D b)

Method Detail

### splitIntoSegments

    public static final java.util.List<Vec2D> splitIntoSegments(Vec2D a,
                                                                Vec2D b,
                                                                float stepLength,
                                                                java.util.List<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

### closestPointTo

    public Vec2D closestPointTo(ReadonlyVec2D p)

  Computes the closest point on this line to the point given.

  Parameters:
    `p` - point to check against
  Returns:
    closest point on the line

### copy

    public Line2D copy()

### equals

    public boolean equals(java.lang.Object obj)

  Overrides:
    `equals` in class `java.lang.Object`

### getDirection

    public Vec2D getDirection()

### getLength

    public float getLength()

### getLengthSquared

    public float getLengthSquared()

### getMidPoint

    public Vec2D getMidPoint()

### getNormal

    public Vec2D getNormal()

### getTheta

    public float getTheta()

### hasEndPoint

    public boolean hasEndPoint(Vec2D p)

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### 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

### offsetAndGrowBy

    public Line2D offsetAndGrowBy(float offset,
                                  float scale,
                                  Vec2D ref)

### scale

    public Line2D scale(float scale)

### set

    public Line2D set(Vec2D a,
                      Vec2D b)

### splitIntoSegments

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

### toRay2D

    public Ray2D toRay2D()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD