|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.java.dev.joode.util.Line2D
public class Line2D
Implementation of a line and some math to go with it. Ported from Phys2D
| Constructor Summary | |
|---|---|
Line2D(float[] x1,
float[] x2)
Create a new line based on two points |
|
Line2D(float x,
float y)
Create a new line based on the origin and a single point |
|
Line2D(float x1,
float y1,
float x2,
float y2)
Create a new line based on two points |
|
Line2D(ROVector2 start,
ROVector2 end)
Create a new line based on two points |
|
| Method Summary | |
|---|---|
float |
distance(ROVector2 point)
Get the shortest distance from a point to this line |
float |
distanceSquared(ROVector2 point)
Get the shortest distance squared from a point to this line |
void |
getClosestPoint(ROVector2 point,
Vector2 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 |
ROVector2 |
getEnd()
Get the end point of the line |
Line2D |
getPositionedLine(ROVector2 displacement,
float rotation)
Get a line starting a x,y and ending offset from the current end point. |
ROVector2 |
getStart()
Get the start point of the line |
Vector2[] |
getVertices(ROVector2 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 |
Vector2 |
intersect(Line2D 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(ROVector2 v)
Move this line a certain amount |
void |
set(ROVector2 start,
ROVector2 end)
Configure the line |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Line2D(float x,
float y)
x - The end point of the liney - The end point of the line
public Line2D(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 point
public Line2D(float[] x1,
float[] x2)
x1 - The start coordinate packed into a two element arrayx2 - The end coordinate packed into a two element array
public Line2D(ROVector2 start,
ROVector2 end)
start - The start pointend - The end point| Method Detail |
|---|
public ROVector2 getStart()
public ROVector2 getEnd()
public float length()
public float lengthSquared()
public void set(ROVector2 start,
ROVector2 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(ROVector2 point)
point - The point from which we want the distance
public float distanceSquared(ROVector2 point)
point - The point from which we want the distance
public void getClosestPoint(ROVector2 point,
Vector2 result)
point - The point which we want to projectresult - The point on the line closest to the given point
public Line2D getPositionedLine(ROVector2 displacement,
float rotation)
displacement - The displacement of the linerotation - The rotation of the line in radians
public Vector2[] getVertices(ROVector2 displacement,
float rotation)
displacement - The displacement of the linerotation - The rotation of the line in radians
public void move(ROVector2 v)
v - The amount to move the linepublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public Vector2 intersect(Line2D 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 | ||||||||