Class Straight
- java.lang.Object
-
- org.eclipse.gef.geometry.euclidean.Straight
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
public class Straight extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable
Represents a straight line within 2-dimensional Euclidean space.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Straight
clone()
boolean
contains(Vector vector)
boolean
containsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector)
boolean
equals(java.lang.Object other)
Angle
getAngle(Straight other)
Angle
getAngleCCW(Straight other)
Angle
getAngleCW(Straight other)
Straight
getCopy()
Returns a copy of thisStraight
object.double
getDistance(Vector vector)
Returns the distance of the providedVector
to thisStraight
, which is the distance between the providedVector
and its projection onto thisStraight
(seegetProjection(Vector)
).Vector
getIntersection(Straight other)
double
getParameterAt(Vector vp)
Vector
getPositionVectorAt(double parameter)
Vector
getProjection(Vector vector)
double
getSignedDistanceCCW(Vector vector)
static double
getSignedDistanceCCW(Point p, Point q, Point r)
double
getSignedDistanceCW(Vector vector)
int
hashCode()
boolean
intersects(Straight other)
boolean
intersectsWithinSegment(Vector segmentStart, Vector segmentEnd, Straight other)
boolean
isParallelTo(Straight other)
Checks if thisStraight
and the provided one are parallel to each other.java.lang.String
toString()
-
-
-
Method Detail
-
getSignedDistanceCCW
public static double getSignedDistanceCCW(Point p, Point q, Point r)
Computes the counter-clockwise (CCW) signed distance of the third
Point
to theStraight
through the first twoPoint
s.The CCW signed distance is positive if the three
Point
s are in counter-clockwise order and negative if thePoint
s are in clockwise order. It is zero if the thirdPoint
lies on the line.If the first two
Point
s are equal to each other, this method returns the distance of the firstPoint
to the lastPoint
.
-
clone
public Straight clone()
- Overrides:
clone
in classjava.lang.Object
-
contains
public boolean contains(Vector vector)
-
containsWithinSegment
public boolean containsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector)
Checks if thePoint
indicated by the providedVector
is aPoint
on theStraight
segment between the given start and endPoint
s indicated by their corresponding positionVector
s.- Parameters:
segmentStart
- AVector
indicating the startPoint
of the segment. It has to lie on thisStraight
.segmentEnd
- AVector
indicating the endPoint
of the segment. It has to lie on thisStraight
.vector
- TheVector
that is checked for containment.- Returns:
true
if thePoint
indicated by the givenVector
lies on thisStraight
, within the specified segment, otherwisefalse
-
equals
public boolean equals(java.lang.Object other)
Checks if thisStraight
is equal to the providedStraight
. TwoStraight
s s1 and s2 are equal, if the positionVector
of s2 is aPoint
on s1 and the directionVector
s of s1 and s2 are parallel.- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getAngleCCW
public Angle getAngleCCW(Straight other)
Returns the counter-clockwise (CCW) or positive
Angle
spanned between the twoStraight
s.The returned
Angle
is the semi-opposite (seeAngle.getOppositeSemi()
) of theAngle
returned by thegetAngleCW(Straight)
method except that for 180deg/0deg, both methods return anAngle
of 0deg.
-
getAngleCW
public Angle getAngleCW(Straight other)
Returns the clockwise (CW) or negative
Angle
spanned between the twoStraight
s.The returned
Angle
is the semi-opposite (seeAngle.getOppositeSemi()
) of theAngle
returned by thegetAngleCCW(Straight)
method except that for 180deg/0deg, both methods return anAngle
of 0deg.
-
getCopy
public Straight getCopy()
Returns a copy of thisStraight
object.- Returns:
- a copy of this
Straight
object.
-
getDistance
public double getDistance(Vector vector)
Returns the distance of the providedVector
to thisStraight
, which is the distance between the providedVector
and its projection onto thisStraight
(seegetProjection(Vector)
).
-
getParameterAt
public double getParameterAt(Vector vp)
Returns this
Straight
's parameter value for the givenVector
. If the givenVector
is not on thisStraight
anIllegalArgumentException
is thrown.This method is the reverse of the
getPositionVectorAt(double)
method.
-
getPositionVectorAt
public Vector getPositionVectorAt(double parameter)
Returns the
Vector
on thisStraight
at the given parameter value. TheVector
that you get is calculated by multiplying thisStraight
's directionVector
by the parameter value and translating thatVector
by thisStraight
's positionVector
.This method is the reverse of the
getParameterAt(Vector)
method.
-
getSignedDistanceCCW
public double getSignedDistanceCCW(Vector vector)
Returns the counter-clockwise (CCW) signed distance of the given
Vector
to thisStraight
.The CCW signed distance indicates on which side of the
Straight
theVector
lies. If it lies on the right side of thisStraight
's directionVector
, the CCW signed distance is negative. If it is on the left side of thisStraight
's directionVector
, it is positive.
-
getSignedDistanceCW
public double getSignedDistanceCW(Vector vector)
Returns the clockwise (CW) signed distance of the given
Vector
to thisStraight
.The CW signed distance indicates on which side of the
Straight
theVector
lies. If it is on the right side of thisStraight
's directionVector
, the CW signed distance is positive. If it is on the left side of thisStraight
's directionVector
, it is negative.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
intersects
public boolean intersects(Straight other)
-
intersectsWithinSegment
public boolean intersectsWithinSegment(Vector segmentStart, Vector segmentEnd, Straight other)
Checks whether thisStraight
and the provided one have an intersectionPoint
which is inside the specified segment between the segmentStart and segmentEndVector
s.- Parameters:
segmentStart
- AVector
indicating the startPoint
of the segment. It has to be aPoint
on theStraight
.segmentEnd
- AVector
indicating the endPoint
of the segment. It has to be aPoint
on theStraight
.other
- TheStraight
to test.- Returns:
true
if the twoStraight
s intersect and the intersectionPoint
is contained within the specified segment, otherwisefalse
-
isParallelTo
public boolean isParallelTo(Straight other)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
-