| Modifier and Type | Field and Description |
|---|---|
protected processing.core.PApplet |
parent
The PApplet object for drawing thinks.
|
| Constructor and Description |
|---|
Line(processing.core.PApplet parent,
float startX,
float startY,
float endX,
float endY)
Builds a new line with the given parameters.
|
Line(processing.core.PApplet parent,
processing.core.PVector start,
float angle,
float length)
Builds a new line with the given parameters.
|
Line(processing.core.PApplet parent,
processing.core.PVector start,
processing.core.PVector end)
Builds a new line with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
computeMinMax()
Forces to calculate the bounds of this shape and store them.
|
Line |
copy()
Builds and returns a true copy of this shape.
|
Line |
draw()
Draws the shape-
|
processing.core.PVector |
get(int i)
Returns the coordinate with index i.
|
Rect |
getBoundingBox()
Returns the bounding box of this shape (will mark the bounds of the
shape).
|
processing.core.PVector |
getCenter()
Returns the center coordinate of this shape.
|
processing.core.PVector[] |
getCoordinates()
Returns all coordinates that defines this shape.
|
processing.core.PVector |
getEnd()
Returns the end coordinate for this shape.
|
float |
getLength()
Returns the length (distance from start to end) of this line.
|
processing.core.PVector |
getNormal()
Returns a normal vector for this line.
|
static processing.core.PVector |
getNormal(processing.core.PVector p,
processing.core.PVector o)
Returns a normal vector for that is described by the given vectors.
|
Line |
getNormalLine(float lineLength)
Builds a line, that represents the normal of this line.
|
java.lang.Float |
getRotation()
Returns the angle of shape.
|
processing.core.PVector |
getStart()
Returns the start coordinate for this shape.
|
java.lang.Float |
getX()
Returns the x-position of the start coordinate for this shape.
|
java.lang.Float |
getY()
Returns the y-position of the start coordinate for this shape.
|
boolean |
hasIntersection(Line other)
Tests if two lines have an intersection.
|
boolean |
hasIntersection(Line other,
boolean ignoreStartEnd)
Tests if two lines have an intersection.
|
static boolean |
hasIntersection(Line base,
Line other)
Tests if two lines have an intersection.
|
static boolean |
hasIntersection(Line base,
Line other,
boolean ignoreStartEnd)
Tests if two lines have an intersection.
|
processing.core.PVector |
intersection(Line other)
Returns the location of an intersection of two lines if they have an
intersection.
|
processing.core.PVector |
intersection(Line other,
boolean ignoreStartEnd)
Returns the location of an intersection of two lines if they have an
intersection.
|
static processing.core.PVector |
intersection(Line base,
Line other)
Returns the location of an intersection of two lines if they have an
intersection.
|
static processing.core.PVector |
intersection(Line base,
Line other,
boolean ignoreStartEnd)
Returns the location of an intersection of two lines if they have an
intersection.
|
static void |
removeIntersectingLines(java.util.ArrayList<Line> lines)
Removes lines from the given set of lines if they intersect with other
lines of the list.
|
static void |
removeIntersectingLines(java.util.ArrayList<Line> lines,
boolean ignoreStartEnd)
Removes lines from the given set of lines if they intersect with other
lines of the list.
|
static void |
removeIntersectingLinesHierarchical(java.util.ArrayList<Line> lines)
Removes lines from the given set of lines if they intersect with other
lines of the list.
|
static void |
removeIntersectingLinesHierarchical(java.util.ArrayList<Line> lines,
boolean ignoreStartEnd)
Removes lines from the given set of lines if they intersect with other
lines of the list.
|
Line |
rotate(float angle)
Turns the shape through the given angle.
|
Line |
rotate(processing.core.PVector rotationCenter,
float angle)
Turns the shape through the given angle.
|
Line |
scale(float scale)
Scale the shape by the given scaling factor.
|
Line |
scale(processing.core.PVector scaleCenter,
float scale)
Scale the shape by the given scaling factor.
|
Line |
setLength(float length)
Sets the length of this line.
|
Line |
setLength(processing.core.PVector center,
float length)
Sets the length of this line.
|
Line |
setLocation(float x,
float y)
Translates the shape to the given location.
|
Line |
setRotation(float angle)
Rotates the shape to the given angle (past rotations will be overridden).
|
Line |
setRotation(processing.core.PVector rotationCenter,
float angle)
Rotates the shape to the given angle (past rotations will be overridden).
|
Line |
setX(float x)
Translates the shape to the given x-location.
|
Line |
setY(float y)
Translates the shape to the given y-location.
|
int |
size()
Returns the number of coordinates for this shape.
|
static Line[] |
toLines(processing.core.PApplet parent,
processing.core.PVector[] points)
Creates lines from the given point set.
|
processing.core.PVector |
toRotationVector()
Creates a vector that points in the same direction like this line.
|
Line |
translate(float x,
float y)
Translates the coordinates by the given parameters x, y ( "moves
the shape by x, y").
|
public Line(processing.core.PApplet parent,
processing.core.PVector start,
processing.core.PVector end)
parent - The PApplet object.start - The start-location of the line.end - The end-location of the line.public Line(processing.core.PApplet parent,
float startX,
float startY,
float endX,
float endY)
parent - The PApplet object.startX - The start-x-location of the line.startY - The start-y-location of the rectangle (top-left corner).endX - The end-x-location of the line.endY - The end-y-location of the line.public Line(processing.core.PApplet parent,
processing.core.PVector start,
float angle,
float length)
parent - The PApplet object.start - The start-location of the line.angle - The rotation of the line (in radians).length - The length of the line.public int size()
RShape
for (int i = 0; i < myShape.size(); i++) {
PVector p = myShape.get(i);
}
public processing.core.PVector get(int i)
RShape
for (int i = 0; i < myShape.size(); i++) {
PVector p = myShape.get(i);
}
public processing.core.PVector getStart()
RShapepublic processing.core.PVector getEnd()
public Rect getBoundingBox()
RShapegetBoundingBox in interface RShapepublic processing.core.PVector getCenter()
RShapepublic java.lang.Float getX()
RShapepublic java.lang.Float getY()
RShapepublic float getLength()
public processing.core.PVector[] getCoordinates()
RShapegetCoordinates in interface RShapepublic processing.core.PVector getNormal()
public Line getNormalLine(float lineLength)
lineLength - The length of the normal line.public java.lang.Float getRotation()
RShapegetRotation in interface RShapepublic Line copy()
RShapepublic Line setRotation(float angle)
RShapesetRotation in interface RShapeangle - The target rotation angle.public Line setRotation(processing.core.PVector rotationCenter, float angle)
RShapesetRotation in interface RShaperotationCenter - The rotation center.angle - The target rotation angle.public Line setLength(float length)
length - The new length of the line (> 0).public Line setLength(processing.core.PVector center, float length)
center - The control point for the scaling.length - The new length of the line (> 0).public Line setX(float x)
RShapepublic Line setY(float y)
RShapepublic Line setLocation(float x, float y)
RShapesetLocation in interface RShapex - The new x-position of this shape.y - The new y-position of this shape.public processing.core.PVector intersection(Line other)
other - One line.public processing.core.PVector intersection(Line other, boolean ignoreStartEnd)
other - One line.ignoreStartEnd - If true, intersections that happen directly at the start or
the end of any line will be ignored (i.e. if the intersection
happens at start / end then still null will be returned).
Otherwise all found intersections will be returned.public boolean hasIntersection(Line other)
other - One line.public boolean hasIntersection(Line other, boolean ignoreStartEnd)
other - One line.ignoreStartEnd - If true, intersections that happen directly at the start or
the end of any line will be ignored (i.e. if the intersection
happens at start / end then still false will be returned).public Line translate(float x, float y)
RShapepublic Line rotate(float angle)
RShapepublic Line rotate(processing.core.PVector rotationCenter, float angle)
RShapepublic Line scale(float scale)
RShapepublic Line scale(processing.core.PVector scaleCenter, float scale)
RShapepublic void computeMinMax()
public static processing.core.PVector getNormal(processing.core.PVector p,
processing.core.PVector o)
p - One location (p != o).o - Another location (p != o).public static Line[] toLines(processing.core.PApplet parent, processing.core.PVector[] points)
parent - The PApplet object.points - Some coordinates (points.length >= 2).public static processing.core.PVector intersection(Line base, Line other)
base - One line.other - Another line.public static processing.core.PVector intersection(Line base, Line other, boolean ignoreStartEnd)
base - One line.other - Another line.ignoreStartEnd - If true, intersections that happen directly at the start or
the end of any line will be ignored (i.e. if the intersection
happens at start / end then still null will be returned).
Otherwise all found intersections will be returned.public static boolean hasIntersection(Line base, Line other)
base - One line.other - Another line.public static boolean hasIntersection(Line base, Line other, boolean ignoreStartEnd)
base - One line.other - Another line.ignoreStartEnd - If true, intersections that happen directly at the start or
the end of any line will be ignored (i.e. if the intersection
happens at start / end then still false will be returned).public static void removeIntersectingLines(java.util.ArrayList<Line> lines)
lines - A set of lines.public static void removeIntersectingLines(java.util.ArrayList<Line> lines, boolean ignoreStartEnd)
lines - A set of lines.ignoreStartEnd - If true, intersections that happen directly at the start or
the end of any line will be ignored (i.e. if the intersection
happens at start / end then the lines will not be removed).public static void removeIntersectingLinesHierarchical(java.util.ArrayList<Line> lines)
lines - A set of lines.public static void removeIntersectingLinesHierarchical(java.util.ArrayList<Line> lines, boolean ignoreStartEnd)
lines - A set of lines.ignoreStartEnd - If true, intersections that happen directly at the start or
the end of any line will be ignored (i.e. if the intersection
happens at start / end then the lines will not be removed).public processing.core.PVector toRotationVector()