|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.geom.LineSegment
public class LineSegment
This class represents a line segment in the plane. A line segment is defined by its two end points.
Constructor Summary | |
---|---|
LineSegment(YPoint p1,
YPoint p2)
Returns a new LineSegment. |
Method Summary | |
---|---|
static boolean |
boxIntersectsSegment(YRectangle box,
double x1,
double y1,
double x2,
double y2)
Checks whether a line segment intersects a box. |
static boolean |
boxIntersectsSegment(YRectangle box,
YPoint s,
YPoint t)
Checks whether a line segment intersects a box. |
boolean |
contains(YPoint point)
Checks whether a given point lies on this line segment. |
YRectangle |
getBoundingBox()
Returns the smallest Rectangle which contains the object. |
double |
getDeltaX()
Returns the distance from start to end point in x-coordinates. |
double |
getDeltaY()
Returns the distance from start to end point in y-coordinates. |
YPoint |
getFirstEndPoint()
Returns the first end point of the line segment. |
static YPoint |
getIntersection(LineSegment s1,
LineSegment s2)
Returns intersection point between the two line segments, if there is one or null if the two line segments do not intersect. |
double |
getScope()
Returns the scope of the line segment. |
YPoint |
getSecondEndPoint()
Returns the second end point of the line segment. |
double |
getXOffset()
Returns the y value of the line on x coordinate 0. |
boolean |
intersects(YPoint p)
Checks whether the line segment intersects a point. |
boolean |
intersects(YRectangle box)
Checks whether the line segment intersects a box. |
boolean |
isHorizontal()
Determines if the interval is horizontal. |
boolean |
isInXIntervall(double x)
Returns if the projection on the X axis of the line segment covers a certain point on the X Axis. |
boolean |
isInYIntervall(double y)
Returns if the projection on the Y axis of the line segment covers a certain point on the Y Axis. |
boolean |
isVertical()
Returns if this segment is considered vertical, i.e. the x values of the end point differ less then 0.00000001 |
double |
length()
Returns the length of the line segment, this is the value of the Euclidean norm. |
AffineLine |
toAffineLine()
Returns the affine line defined by the end points of the line segment. |
String |
toString()
String representation of the line. |
YVector |
toYVector()
Returns the vector pointing from the first end point to the second end point of the line segment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LineSegment(YPoint p1, YPoint p2)
p1
- the first end point of the line segment.p2
- the second end point of the line segment.Method Detail |
---|
public boolean isVertical()
true
if this segment is considered vertical, false
otherwise.public boolean isHorizontal()
true
if the interval is horizontal, false
otherwise.public YPoint getFirstEndPoint()
public YPoint getSecondEndPoint()
public boolean isInYIntervall(double y)
public boolean isInXIntervall(double x)
public double getXOffset()
public double getScope()
public double length()
public YRectangle getBoundingBox()
getBoundingBox
in interface PlaneObject
public boolean intersects(YRectangle box)
box
- A rectangle.
true
if the line segments intersects the box,
false
otherwise.public boolean contains(YPoint point)
point
- an arbitrary point.
true
if the line segments intersects the box,
false
otherwise.public boolean intersects(YPoint p)
p
- a point
true
if the line segments intersects the box,
false
otherwise.public static final boolean boxIntersectsSegment(YRectangle box, YPoint s, YPoint t)
box
- A rectangle.s
- first end point of the line segment.t
- second end point of the line segment.
true
if the line segments intersects the box,
false
otherwise.public static final boolean boxIntersectsSegment(YRectangle box, double x1, double y1, double x2, double y2)
box
- A rectanglex1
- X-coordinate of start point of vectory1
- Y-coordinate of start point of vectorx2
- X-coordinate of target point of vectory2
- Y-coordinate of target point of vector
true
if the line segments intersects the box,
false
otherwise.public static YPoint getIntersection(LineSegment s1, LineSegment s2)
null
if the two line segments do not intersect.
s1
- first line segments2
- second line segmentpublic YVector toYVector()
public AffineLine toAffineLine()
public double getDeltaX()
public double getDeltaY()
public String toString()
toString
in class Object
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |