Package org.eclipse.gef.geometry.euclidean

# Class Straight

java.lang.Object
org.eclipse.gef.geometry.euclidean.Straight

All Implemented Interfaces:
  `Serializable`, `Cloneable`

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

See Also:
  - Serialized Form

## Field Summary

Fields
Modifier and Type
Field
Description
`Vector`
`direction`
The direction `Vector` of this `Straight`.
`Vector`
`position`
The position `Vector` of this `Straight`.

## Constructor Summary

Constructors
Constructor
Description
`Straight(Vector position, Vector direction)`
Constructs a new `Straight` with the given position `Vector` and direction `Vector`.
`Straight(Line line)`
Constructs a new `Straight` through the start and end `Point` of the given `Line`.
`Straight(Point point1, Point point2)`
Constructs a new `Straight` that passes through the two given `Point`s.

## Method Summary

Modifier and Type
Method
Description
`Straight`
`clone()`
`boolean`
`contains(Vector vector)`
Checks if the `Point` indicated by the provided `Vector` is a `Point` on this `Straight`.
`boolean`
`containsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector)`
Checks if the `Point` indicated by the provided `Vector` is a `Point` on the `Straight` segment between the given start and end `Point`s indicated by their corresponding position `Vector`s.
`boolean`
`equals(Object other)`
Checks if this `Straight` is equal to the provided `Straight` .
`Angle`
`getAngle(Straight other)`
Returns the (smallest) `Angle` between this `Straight` and the provided one.
`Angle`
`getAngleCCW(Straight other)`
Returns the counter-clockwise (CCW) or positive `Angle` spanned between the two `Straight`s.
`Angle`
`getAngleCW(Straight other)`
Returns the clockwise (CW) or negative `Angle` spanned between the two `Straight`s.
`Straight`
`getCopy()`
Returns a copy of this `Straight` object.
`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` (see `getProjection(Vector)`).
`Vector`
`getIntersection(Straight other)`
Computes and returns the position `Vector` of the intersection of this `Straight` and the provided one.
`double`
`getParameterAt(Vector vp)`
Returns this `Straight`'s parameter value for the given `Vector`.
`Vector`
`getPositionVectorAt(double parameter)`
Returns the `Vector` on this `Straight` at the given parameter value.
`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`.
`double`
`getSignedDistanceCCW(Vector vector)`
Returns the counter-clockwise (CCW) signed distance of the given `Vector` to this `Straight`.
`static double`
`getSignedDistanceCCW(Point p, Point q, Point r)`
Computes the counter-clockwise (CCW) signed distance of the third `Point` to the `Straight` through the first two `Point` s.
`double`
`getSignedDistanceCW(Vector vector)`
Returns the clockwise (CW) signed distance of the given `Vector` to this `Straight`.
`int`
`hashCode()`
`boolean`
`intersects(Straight other)`
Checks whether this `Straight` and the provided one have a single `Point` of intersection.
`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 the segmentStart and segmentEnd `Vector`s.
`boolean`
`isParallelTo(Straight other)`
Checks if this `Straight` and the provided one are parallel to each other.
`String`
`toString()`

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

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

## Field Details

### position

public Vector position
The position `Vector` of this `Straight`.

### direction

public Vector direction
The direction `Vector` of this `Straight`.

## Constructor Details

### Straight

public Straight(Line line)
Constructs a new `Straight` through the start and end `Point` of the given `Line`.

Parameters:
  `line` - the `Line` which the new `Straight` shall pass through

### Straight

public Straight(Point point1, Point point2)
Constructs a new `Straight` that passes through the two given `Point`s.

Parameters:
  `point1` - a first waypoint of the `Straight` to be constructed
  `point2` - a second waypoint of the `Straight` to be constructed

### Straight

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

Parameters:
  `position` - a support `Vector` of the new `Straight`
  `direction` - a direction `Vector` of the new `Straight`

## Method Details

### getSignedDistanceCCW

public static double getSignedDistanceCCW(Point p, Point q, Point r)

Computes the counter-clockwise (CCW) signed distance of the third `Point` to the `Straight` through the first two `Point` s.

The CCW signed distance is positive if the three `Point`s are in counter-clockwise order and negative if the `Point`s are in clockwise order. It is zero if the third `Point` lies on the line.

If the first two `Point`s are equal to each other, this method returns the distance of the first `Point` to the last `Point` .

Parameters:
  `p` - the start `Point` of the `Straight`
  `q` - the end `Point` of the `Straight`
  `r` - the relative `Point`
Returns:
  the CCW signed distance of the `Point` r to the `Straight` through `Point`s p and q

### clone

public Straight clone()

Overrides:
  `clone` in class `Object`

### contains

public boolean contains(Vector vector)
Checks if the `Point` indicated by the provided `Vector` is a `Point` on this `Straight`.

Parameters:
  `vector` - the `Vector` that is checked to lie on this `Straight`
Returns:
  `true` if the `Point` indicated by the given `Vector` is a `Point` of this `Straight`, otherwise `false`

### containsWithinSegment

public boolean containsWithinSegment(Vector segmentStart, Vector segmentEnd, Vector vector)
Checks if the `Point` indicated by the provided `Vector` is a `Point` on the `Straight` segment between the given start and end `Point`s indicated by their corresponding position `Vector`s.

Parameters:
  `segmentStart` - A `Vector` indicating the start `Point` of the segment. It has to lie on this `Straight`.
  `segmentEnd` - A `Vector` indicating the end `Point` of the segment. It has to lie on this `Straight`.
  `vector` - The `Vector` that is checked for containment.
Returns:
  `true` if the `Point` indicated by the given `Vector` lies on this `Straight`, within the specified segment, otherwise `false`

### equals

public boolean equals(Object other)
Checks if this `Straight` is equal to the provided `Straight` . Two `Straight`s s1 and s2 are equal, if the position `Vector` of s2 is a `Point` on s1 and the direction `Vector`s of s1 and s2 are parallel.

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

### getAngle

public Angle getAngle(Straight other)
Returns the (smallest) `Angle` between this `Straight` and the provided one.

Parameters:
  `other` - the `Straight` to compute the `Angle` with
Returns:
  the `Angle` spanned between the two `Straight`s

### getAngleCCW

public Angle getAngleCCW(Straight other)

Returns the counter-clockwise (CCW) or positive `Angle` spanned between the two `Straight`s.

The returned `Angle` is the semi-opposite (see `Angle.getOppositeSemi()`) of the `Angle` returned by the `getAngleCW(Straight)` method except that for 180deg/0deg, both methods return an `Angle` of 0deg.

Parameters:
  `other` - The `Straight` to which the `Angle` is computed.
Returns:
  the counter-clockwise (CCW) or positive `Angle` spanned between the two `Straight`s

### getAngleCW

public Angle getAngleCW(Straight other)

Returns the clockwise (CW) or negative `Angle` spanned between the two `Straight`s.

The returned `Angle` is the semi-opposite (see `Angle.getOppositeSemi()`) of the `Angle` returned by the `getAngleCCW(Straight)` method except that for 180deg/0deg, both methods return an `Angle` of 0deg.

Parameters:
  `other` - The `Straight` to which the `Angle` is computed.
Returns:
  the clockwise (CW) or negative `Angle` spanned between the two `Straight`s

### getCopy

public Straight getCopy()
Returns a copy of this `Straight` object.

Returns:
  a copy of this `Straight` object.

### 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` (see `getProjection(Vector)`).

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

### getIntersection

public Vector getIntersection(Straight other)
Computes and returns the position `Vector` of the intersection of this `Straight` and the provided one. If the two `Straight`s are parallel or identical, `null` is returned.

Parameters:
  `other` - the `Straight` to compute the position `Vector` of the intersection with
Returns:
  a `Vector` pointing to the intersection point, `null` if no intersection `Point` exists

### getParameterAt

public double getParameterAt(Vector vp)

Returns this `Straight`'s parameter value for the given `Vector`. If the given `Vector` is not on this `Straight` an `IllegalArgumentException` is thrown.

This method is the reverse of the `getPositionVectorAt(double)` method.

Parameters:
  `vp` - a `Vector` on this `Straight` for which the parameter value is to be calculated
Returns:
  this `Straight`'s parameter value for the given `Vector`

### getPositionVectorAt

public Vector getPositionVectorAt(double parameter)

Returns the `Vector` on this `Straight` at the given parameter value. The `Vector` that you get is calculated by multiplying this `Straight`'s direction `Vector` by the parameter value and translating that `Vector` by this `Straight`'s position `Vector`.

This method is the reverse of the `getParameterAt(Vector)` method.

Parameters:
  `parameter` - the parameter value for which the corresponding `Vector` on this `Straight` is to be calculated
Returns:
  the `Vector` on this `Straight` at the passed-in parameter value

### 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`

### getSignedDistanceCCW

public double getSignedDistanceCCW(Vector vector)

Returns the counter-clockwise (CCW) signed distance of the given `Vector` to this `Straight`.

The CCW signed distance indicates on which side of the `Straight` the `Vector` lies. If it lies on the right side of this `Straight`'s direction `Vector`, the CCW signed distance is negative. If it is on the left side of this `Straight`'s direction `Vector`, it is positive.

Parameters:
  `vector` - the `Vector` for which the CCW signed distance to this `Straight` is to be calculated
Returns:
  the CCW signed distance of the given `Vector` to this `Straight`

### getSignedDistanceCW

public double getSignedDistanceCW(Vector vector)

Returns the clockwise (CW) signed distance of the given `Vector` to this `Straight`.

The CW signed distance indicates on which side of the `Straight` the `Vector` lies. If it is on the right side of this `Straight`'s direction `Vector`, the CW signed distance is positive. If it is on the left side of this `Straight`'s direction `Vector`, it is negative.

Parameters:
  `vector` - the `Vector` for which the CW signed distance to this `Straight` is to be calculated
Returns:
  the CW signed distance of the given `Vector` to this `Straight`

### hashCode

public int hashCode()

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

### intersects

public boolean intersects(Straight other)
Checks whether this `Straight` and the provided one have a single `Point` of intersection.

Parameters:
  `other` - the `Straight` to test for an intersection `Point` with this `Straight`
Returns:
  `true` if the two `Straight`s intersect in one single `Point`, otherwise `false`

### 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 the segmentStart and segmentEnd `Vector`s.

Parameters:
  `segmentStart` - A `Vector` indicating the start `Point` of the segment. It has to be a `Point` on the `Straight`.
  `segmentEnd` - A `Vector` indicating the end `Point` of the segment. It has to be a `Point` on the `Straight`.
  `other` - The `Straight` to test.
Returns:
  `true` if the two `Straight`s intersect and the intersection `Point` is contained within the specified segment, otherwise `false`

### isParallelTo

public boolean isParallelTo(Straight other)
Checks if this `Straight` and the provided one are parallel to each other. Identical `Straight`s are regarded to be parallel to each other.

Parameters:
  `other` - the `Straight` that is checked to be parallel to this `Straight`
Returns:
  `true` if the direction `Vector`s of this `Straight` and the provided one are parallel, otherwise `false`

### toString

public String toString()

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