Package org.eclipse.draw2d.geometry
Class Straight
java.lang.Object
org.eclipse.draw2d.geometry.Straight
Represents a straight line within 2-dimensional Euclidean space.
- Since:
- 3.6
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionStraight(PrecisionPoint point1, PrecisionPoint point2) Constructs a new Straight between the two given Points.Constructs a new Straight with the given position and direction.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanCalculates whether the point indicated by the provided Vector is a point on this Straight.booleancontainsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector) Calculates whether the point indicated by the provided Vector is a point on the straight segment between the given start and end points.booleanChecks whether this Straight is equal to the provided Straight.doubleReturns the (smallest) angle between this Straight and the provided one.doublegetDistance(Vector vector) Returns the distance of the provided Vector to this Straight, which is the distance between the provided Vector and its projection onto this Straight.getIntersection(Straight other) Computes the intersection point of this Straight and the provided one, if it exists.getProjection(Vector vector) Returns the projection of the given Vector onto this Straight, which is the point on this Straight with the minimal distance to the point, denoted by the provided Vector.inthashCode()booleanintersects(Straight other) Checks whether this Straight and the provided one have an intersection point.booleanintersectsWithinSegment(Vector segmentStart, Vector segmentEnd, Straight other) Checks whether this Straight and the provided one have an intersection point, which is inside the specified segment between segmentStart and segmentEnd.booleanisParallelTo(Straight other) Checks whether this Straight and the provided one are parallel to each other.toString()
- 
Field Details- 
positionposition vector of this straight
- 
directiondirection vector of this straight
 
- 
- 
Constructor Details- 
StraightConstructs a new Straight with the given position and direction.- Parameters:
- position-
- direction-
 
- 
StraightConstructs a new Straight between the two given Points.- Parameters:
- point1- a first waypoint of the Straight to be constructed
- point2- a second waypoint of the Straight to be constructed
 
 
- 
- 
Method Details- 
intersectsChecks whether this Straight and the provided one have an intersection point.- Parameters:
- other- The Straight to use for the calculation.
- Returns:
- true if the two Straights intersect, false otherwise.
 
- 
intersectsWithinSegmentChecks whether this Straight and the provided one have an intersection point, which is inside the specified segment between segmentStart and segmentEnd. segmentStart a Vector indicating the start point of the segment. Has to be a point on the straight.- Parameters:
- segmentEnd- a Vector indicating the end point of the segment. Has to be a point on the straight.
- other- the Straight to test
- Returns:
- true if the true straights intersect and the intersection point is contained within the specified segment, false otherwise.
- Since:
- 3.2
 
- 
getIntersectionComputes the intersection point of this Straight and the provided one, if it exists.- Parameters:
- other- The Straight to use for calculations.
- Returns:
- A Vector pointing to the intersection point, if it exists, null if no intersection point exists (or the Straights are equal).
 
- 
getAngleReturns the (smallest) angle between this Straight and the provided one.- Parameters:
- other- The Straight to be used for the calculation.
- Returns:
- The angle spanned between the two Straights.
 
- 
getProjectionReturns the projection of the given Vector onto this Straight, which is the point on this Straight with the minimal distance to the point, denoted by the provided Vector.- Parameters:
- vector- The Vector whose projection should be determined.
- Returns:
- A new Vector representing the projection of the provided Vector onto this Straight.
 
- 
getDistanceReturns the distance of the provided Vector to this Straight, which is the distance between the provided Vector and its projection onto this Straight.- Parameters:
- vector- The Vector whose distance is to be calculated.
- Returns:
- the distance between this Straight and the provided Vector.
 
- 
containsCalculates whether the point indicated by the provided Vector is a point on this Straight.- Parameters:
- vector- the Vector who has to be checked.
- Returns:
- true if the point indicated by the given Vector is a point of this Straight, false otherwise.
 
- 
containsWithinSegmentCalculates whether the point indicated by the provided Vector is a point on the straight segment between the given start and end points.- Parameters:
- segmentStart- a Vector indicating the start point of the segment. Has to be a point on the straight.
- segmentEnd- a Vector indicating the end point of the segment. Has to be a point on the straight.
- vector- the Vector who has to be checked.
- Returns:
- true if point indicated by the given Vector is a point on this straight, within the specified segment, false otherwise.
 
- 
isParallelToChecks whether this Straight and the provided one are parallel to each other.- Parameters:
- other- The Straight to test for parallelism.
- Returns:
- true if the direction vectors of this Straight and the provided one are parallel, false otherwise.
 
- 
equalsChecks whether this Straight is equal to the provided Straight. Two Straights s1 and s2 are equal, if the position vector of s2 is a point on s1 and the direction vectors of s1 and s2 are parallel.
- 
hashCodepublic int hashCode()
- 
toString
 
-