|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.geom.Shape org.newdawn.slick.geom.Line
public class Line
Implemenation of a bunch of maths functions to do with lines. Note that lines can't be used as dynamic shapes right now - also collision with the end of a line is undefined.
Field Summary |
---|
Fields inherited from class org.newdawn.slick.geom.Shape |
---|
boundingCircleRadius, center, maxX, maxY, minX, minY, points, pointsDirty, trianglesDirty, tris, x, y |
Constructor Summary | |
---|---|
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 |
Method Summary | |
---|---|
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. |
Methods inherited from class org.newdawn.slick.geom.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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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 Line(Vector2f start, Vector2f end)
start
- The start pointend
- The end pointMethod Detail |
---|
public 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
getX
in class Shape
Shape.getX()
public float getY()
Shape
getY
in class Shape
Shape.getY()
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 distance
public boolean on(Vector2f point)
point
- The point to check
public float distanceSquared(Vector2f point)
point
- The point from which we want the distance
public 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
Object.toString()
public Vector2f intersect(Line other)
other
- The other line we should intersect with
public 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 lines
public 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 any
protected void createPoints()
Shape
createPoints
in class Shape
Shape.createPoints()
public Shape transform(Transform transform)
Shape
transform
in class Shape
transform
- The transform to be applied
Shape.transform(org.newdawn.slick.geom.Transform)
public boolean closed()
Shape
closed
in class Shape
Shape.closed()
public boolean intersects(Shape shape)
Shape
intersects
in class Shape
shape
- The shape to check if it intersects with this one.
Shape.intersects(org.newdawn.slick.geom.Shape)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |