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.SerializableRepresents 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 Straightclone()booleancontains(Vector vector)booleancontainsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector)booleanequals(java.lang.Object other)AnglegetAngle(Straight other)AnglegetAngleCCW(Straight other)AnglegetAngleCW(Straight other)StraightgetCopy()Returns a copy of thisStraightobject.doublegetDistance(Vector vector)Returns the distance of the providedVectorto thisStraight, which is the distance between the providedVectorand its projection onto thisStraight(seegetProjection(Vector)).VectorgetIntersection(Straight other)doublegetParameterAt(Vector vp)VectorgetPositionVectorAt(double parameter)VectorgetProjection(Vector vector)doublegetSignedDistanceCCW(Vector vector)static doublegetSignedDistanceCCW(Point p, Point q, Point r)doublegetSignedDistanceCW(Vector vector)inthashCode()booleanintersects(Straight other)booleanintersectsWithinSegment(Vector segmentStart, Vector segmentEnd, Straight other)booleanisParallelTo(Straight other)Checks if thisStraightand the provided one are parallel to each other.java.lang.StringtoString()
-
-
-
Method Detail
-
getSignedDistanceCCW
public static double getSignedDistanceCCW(Point p, Point q, Point r)
Computes the counter-clockwise (CCW) signed distance of the third
Pointto theStraightthrough the first twoPoints.The CCW signed distance is positive if the three
Points are in counter-clockwise order and negative if thePoints are in clockwise order. It is zero if the thirdPointlies on the line.If the first two
Points are equal to each other, this method returns the distance of the firstPointto the lastPoint.
-
clone
public Straight clone()
- Overrides:
clonein classjava.lang.Object
-
contains
public boolean contains(Vector vector)
-
containsWithinSegment
public boolean containsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector)
Checks if thePointindicated by the providedVectoris aPointon theStraightsegment between the given start and endPoints indicated by their corresponding positionVectors.- Parameters:
segmentStart- AVectorindicating the startPointof the segment. It has to lie on thisStraight.segmentEnd- AVectorindicating the endPointof the segment. It has to lie on thisStraight.vector- TheVectorthat is checked for containment.- Returns:
trueif thePointindicated by the givenVectorlies on thisStraight, within the specified segment, otherwisefalse
-
equals
public boolean equals(java.lang.Object other)
Checks if thisStraightis equal to the providedStraight. TwoStraights s1 and s2 are equal, if the positionVectorof s2 is aPointon s1 and the directionVectors of s1 and s2 are parallel.- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
getAngleCCW
public Angle getAngleCCW(Straight other)
Returns the counter-clockwise (CCW) or positive
Anglespanned between the twoStraights.The returned
Angleis the semi-opposite (seeAngle.getOppositeSemi()) of theAnglereturned by thegetAngleCW(Straight)method except that for 180deg/0deg, both methods return anAngleof 0deg.
-
getAngleCW
public Angle getAngleCW(Straight other)
Returns the clockwise (CW) or negative
Anglespanned between the twoStraights.The returned
Angleis the semi-opposite (seeAngle.getOppositeSemi()) of theAnglereturned by thegetAngleCCW(Straight)method except that for 180deg/0deg, both methods return anAngleof 0deg.
-
getCopy
public Straight getCopy()
Returns a copy of thisStraightobject.- Returns:
- a copy of this
Straightobject.
-
getDistance
public double getDistance(Vector vector)
Returns the distance of the providedVectorto thisStraight, which is the distance between the providedVectorand its projection onto thisStraight(seegetProjection(Vector)).
-
getParameterAt
public double getParameterAt(Vector vp)
Returns this
Straight's parameter value for the givenVector. If the givenVectoris not on thisStraightanIllegalArgumentExceptionis thrown.This method is the reverse of the
getPositionVectorAt(double)method.
-
getPositionVectorAt
public Vector getPositionVectorAt(double parameter)
Returns the
Vectoron thisStraightat the given parameter value. TheVectorthat you get is calculated by multiplying thisStraight's directionVectorby the parameter value and translating thatVectorby 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
Vectorto thisStraight.The CCW signed distance indicates on which side of the
StraighttheVectorlies. 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
Vectorto thisStraight.The CW signed distance indicates on which side of the
StraighttheVectorlies. 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:
hashCodein 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 thisStraightand the provided one have an intersectionPointwhich is inside the specified segment between the segmentStart and segmentEndVectors.- Parameters:
segmentStart- AVectorindicating the startPointof the segment. It has to be aPointon theStraight.segmentEnd- AVectorindicating the endPointof the segment. It has to be aPointon theStraight.other- TheStraightto test.- Returns:
trueif the twoStraights intersect and the intersectionPointis contained within the specified segment, otherwisefalse
-
isParallelTo
public boolean isParallelTo(Straight other)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
-