public class Line extends Shape
boundingCircleRadius, center, maxX, maxY, minX, minY, points, pointsDirty, trianglesDirty, tris, x, y
Constructor and Description |
---|
Line(float[] start,
float[] end)
Create a new line based on two points
|
Line(float x,
float y)
Create a new line based on the origin and a single point
|
Line(float x,
float y,
boolean inner,
boolean outer)
Create a new line based on the origin and a single point
|
Line(float x1,
float y1,
float x2,
float y2)
Create a new line based on two points
|
Line(float x1,
float y1,
float dx,
float dy,
boolean dummy)
Create a line with relative second point
|
Line(Vector2f start,
Vector2f end)
Create a new line based on two points
|
Modifier and Type | Method and Description |
---|---|
boolean |
closed()
True if this is a closed shape
|
protected void |
createPoints()
Subclasses implement this to create the points of the shape.
|
float |
distance(Vector2f point)
Get the shortest distance from a point to this line
|
float |
distanceSquared(Vector2f point)
Get the shortest distance squared from a point to this line
|
void |
getClosestPoint(Vector2f point,
Vector2f result)
Get the closest point on the line to a given point
|
float |
getDX()
Get the x direction of this line
|
float |
getDY()
Get the y direction of this line
|
Vector2f |
getEnd()
Get the end point of the line
|
Vector2f |
getStart()
Get the start point of the line
|
float |
getX()
Get the x location of the left side of this shape.
|
float |
getX1()
Get the x coordinate of the start point
|
float |
getX2()
Get the x coordinate of the end point
|
float |
getY()
Get the y position of the top of this shape.
|
float |
getY1()
Get the y coordinate of the start point
|
float |
getY2()
Get the y coordinate of the end point
|
Vector2f |
intersect(Line other)
Intersect this line with another
|
Vector2f |
intersect(Line other,
boolean limit)
Intersect this line with another
|
boolean |
intersect(Line other,
boolean limit,
Vector2f result)
Intersect this line with another
|
boolean |
intersects(Shape shape)
Check if this shape intersects with the shape provided.
|
float |
length()
Find the length of the line
|
float |
lengthSquared()
Find the length of the line squared (cheaper and good for comparisons)
|
boolean |
on(Vector2f point)
Check if the given point is on the line
|
void |
set(float[] start,
float[] end)
Configure the line
|
void |
set(float sx,
float sy,
float ex,
float ey)
Configure the line without garbage
|
void |
set(Vector2f start,
Vector2f end)
Configure the line
|
java.lang.String |
toString() |
Shape |
transform(Transform transform)
Apply a transformation and return a new shape.
|
calculateRadius, calculateTriangles, checkPoints, contains, contains, findCenter, getBoundingCircleRadius, getCenter, getCenterX, getCenterY, getHeight, getLocation, getMaxX, getMaxY, getMinX, getMinY, getNormal, getPoint, getPointCount, getPoints, getTriangles, getWidth, hasVertex, includes, increaseTriangulation, indexOf, preCache, prune, setCenterX, setCenterY, setLocation, setLocation, setX, setY, subtract, union
public Line(float x, float y, boolean inner, boolean outer)
x
- The end point of the liney
- The end point of the lineinner
- True if this line blocks on it's inner edgeouter
- True if this line blocks on it's outer edgepublic Line(float x, float y)
x
- The end point of the liney
- The end point of the linepublic Line(float x1, float y1, float x2, float y2)
x1
- The x coordinate of the start pointy1
- The y coordinate of the start pointx2
- The x coordinate of the end pointy2
- The y coordinate of the end pointpublic Line(float x1, float y1, float dx, float dy, boolean dummy)
x1
- The x coordinate of the start pointy1
- The y coordinate of the start pointdx
- The x change to get to the second pointdy
- The y change to get to the second pointdummy
- A dummy valuepublic Line(float[] start, float[] end)
start
- The start pointend
- The end pointpublic void set(float[] start, float[] end)
start
- The start point of the lineend
- The end point of the linepublic Vector2f getStart()
public Vector2f getEnd()
public float length()
public float lengthSquared()
public void set(Vector2f start, Vector2f end)
start
- The start point of the lineend
- The end point of the linepublic void set(float sx, float sy, float ex, float ey)
sx
- The x coordinate of the startsy
- The y coordinate of the startex
- The x coordiante of the endey
- The y coordinate of the endpublic float getDX()
public float getDY()
public float getX()
Shape
public float getY()
Shape
public float getX1()
public float getY1()
public float getX2()
public float getY2()
public float distance(Vector2f point)
point
- The point from which we want the distancepublic boolean on(Vector2f point)
point
- The point to checkpublic float distanceSquared(Vector2f point)
point
- The point from which we want the distancepublic void getClosestPoint(Vector2f point, Vector2f result)
point
- The point which we want to projectresult
- The point on the line closest to the given pointpublic java.lang.String toString()
toString
in class java.lang.Object
public Vector2f intersect(Line other)
other
- The other line we should intersect withpublic Vector2f intersect(Line other, boolean limit)
other
- The other line we should intersect withlimit
- True if the collision is limited to the extent of the linespublic boolean intersect(Line other, boolean limit, Vector2f result)
other
- The other line we should intersect withlimit
- True if the collision is limited to the extent of the linesresult
- The resulting intersection point if anyprotected void createPoints()
Shape
createPoints
in class Shape
public Shape transform(Transform transform)
Shape
public boolean closed()
Shape
public boolean intersects(Shape shape)
Shape
intersects
in class Shape
shape
- The shape to check if it intersects with this one.