|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.phys2d.raw.shapes.AbstractShape net.phys2d.raw.shapes.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 net.phys2d.raw.shapes.AbstractShape |
bounds |
Constructor Summary | |
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(ROVector2f start,
ROVector2f end)
Create a new line based on two points |
Method Summary | |
boolean |
blocksInnerEdge()
Check if this line blocks the inner side (for want of a better term) |
boolean |
blocksOuterEdge()
Check if this line blocks the outer side (for want of a better term) |
float |
distance(ROVector2f point)
Get the shortest distance from a point to this line |
float |
distanceSquared(ROVector2f point)
Get the shortest distance squared from a point to this line |
void |
getClosestPoint(ROVector2f 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 |
ROVector2f |
getEnd()
Get the end point of the line |
Line |
getPositionedLine(ROVector2f displacement,
float rotation)
Get a line starting a x,y and ending offset from the current end point. |
ROVector2f |
getStart()
Get the start point of the line |
float |
getSurfaceFactor()
Some factor based on the edges length of the shape |
Vector2f[] |
getVertices(ROVector2f displacement,
float rotation)
Return a translated and rotated line. |
float |
getX1()
Get the x coordinate of the start point |
float |
getX2()
Get the x coordinate of the end point |
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 |
float |
length()
Find the length of the line |
float |
lengthSquared()
Find the length of the line squared (cheaper and good for comparisons) |
void |
move(ROVector2f v)
Move this line a certain amount |
void |
set(ROVector2f start,
ROVector2f end)
Configure the line |
void |
setBlocksInnerEdge(boolean innerEdge)
Indicate if this line blocks on it's inner edge |
void |
setBlocksOuterEdge(boolean outerEdge)
Indicate if this line blocks on it's outer edge |
java.lang.String |
toString()
|
Methods inherited from class net.phys2d.raw.shapes.AbstractShape |
getBounds |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.phys2d.raw.shapes.Shape |
getBounds |
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(ROVector2f start, ROVector2f end)
start
- The start pointend
- The end pointMethod Detail |
public boolean blocksInnerEdge()
public void setBlocksInnerEdge(boolean innerEdge)
innerEdge
- True if this line blocks on it's inner edgepublic boolean blocksOuterEdge()
public void setBlocksOuterEdge(boolean outerEdge)
outerEdge
- True if this line blocks on it's outer edgepublic ROVector2f getStart()
public ROVector2f getEnd()
public float length()
public float lengthSquared()
public void set(ROVector2f start, ROVector2f end)
start
- The start point of the lineend
- The end point of the linepublic float getDX()
public float getDY()
public float getX1()
public float getY1()
public float getX2()
public float getY2()
public float distance(ROVector2f point)
point
- The point from which we want the distance
public float distanceSquared(ROVector2f point)
point
- The point from which we want the distance
public void getClosestPoint(ROVector2f point, Vector2f result)
point
- The point which we want to projectresult
- The point on the line closest to the given pointpublic float getSurfaceFactor()
Shape
getSurfaceFactor
in interface Shape
Shape.getSurfaceFactor()
public Line getPositionedLine(ROVector2f displacement, float rotation)
displacement
- The displacement of the linerotation
- The rotation of the line in radians
public Vector2f[] getVertices(ROVector2f displacement, float rotation)
displacement
- The displacement of the linerotation
- The rotation of the line in radians
public void move(ROVector2f v)
v
- The amount to move the linepublic java.lang.String toString()
Object.toString()
public Vector2f intersect(Line other)
other
- The other line we should intersect with
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |