Package org.eclipse.draw2d.geometry

# Class Straight

java.lang.Object
org.eclipse.draw2d.geometry.Straight

public class Straight extends Object
Represents a straight line within 2-dimensional Euclidean space.

Since:
  3.6

## Field Summary

Fields
Modifier and Type
Field
Description
`Vector`
`direction`
direction vector of this straight
`Vector`
`position`
position vector of this straight

## Constructor Summary

Constructors
Constructor
Description
`Straight(PrecisionPoint point1, PrecisionPoint point2)`
Constructs a new Straight between the two given Points.
`Straight(Vector position, Vector direction)`
Constructs a new Straight with the given position and direction.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`contains(Vector vector)`
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`
`equals(Object other)`
Checks whether this Straight is equal to the provided Straight.
`double`
`getAngle(Straight other)`
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.
`Vector`
`getIntersection(Straight other)`
Computes the intersection point of this Straight and the provided one, if it exists.
`Vector`
`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.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Field Details

### position

public Vector position
position vector of this straight

### direction

public Vector direction
direction vector of this straight

## Constructor Details

### Straight

public Straight(Vector position, Vector direction)
Constructs a new Straight with the given position and direction.

Parameters:
  `position` -
  `direction` -

### Straight

public Straight(PrecisionPoint point1, PrecisionPoint point2)
Constructs 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

### intersects

public boolean intersects(Straight other)
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

public 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. 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

public Vector getIntersection(Straight other)
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

public double getAngle(Straight other)
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

public Vector 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.

Parameters:
  `vector` - The Vector whose projection should be determined.
Returns:
  A new Vector representing the projection of the provided Vector onto this Straight.

### getDistance

public 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.

Parameters:
  `vector` - The Vector whose distance is to be calculated.
Returns:
  the distance between this Straight and the provided Vector.

### contains

public boolean contains(Vector vector)
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

public 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.

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

public boolean isParallelTo(Straight other)
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

public boolean equals(Object other)
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.

Overrides:
  `equals` in class `Object`
See Also:
  - `Object.equals(java.lang.Object)`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`
See Also:
  - `Object.hashCode()`

### toString

public String toString()

Overrides:
  `toString` in class `Object`
See Also:
  - `Object.toString()`