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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStraight
(PrecisionPoint point1, PrecisionPoint point2) Constructs a new Straight between the two given Points.Constructs a new Straight with the given position and direction. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Calculates whether the point indicated by the provided Vector is a point on this Straight.boolean
containsWithinSegment
(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.boolean
Checks whether this Straight is equal to the provided Straight.double
Returns the (smallest) angle between this Straight and the provided one.double
getDistance
(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.int
hashCode()
boolean
intersects
(Straight other) Checks whether this Straight and the provided one have an intersection point.boolean
intersectsWithinSegment
(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.boolean
isParallelTo
(Straight other) Checks whether this Straight and the provided one are parallel to each other.toString()
-
Field Details
-
position
position vector of this straight -
direction
direction vector of this straight
-
-
Constructor Details
-
Straight
Constructs a new Straight with the given position and direction.- Parameters:
position
-direction
-
-
Straight
Constructs a new Straight between the two given Points.- Parameters:
point1
- a first waypoint of the Straight to be constructedpoint2
- a second waypoint of the Straight to be constructed
-
-
Method Details
-
intersects
Checks 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.
-
intersectsWithinSegment
Checks 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
-
getIntersection
Computes 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).
-
getAngle
Returns 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.
-
getProjection
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.- Parameters:
vector
- The Vector whose projection should be determined.- Returns:
- A new Vector representing the projection of the provided Vector onto this Straight.
-
getDistance
Returns 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.
-
contains
Calculates 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.
-
containsWithinSegment
Calculates 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.
-
isParallelTo
Checks 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.
-
equals
Checks 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. -
hashCode
public int hashCode() -
toString
-