Eclipse Draw2d
3.3

org.eclipse.draw2d.geometry
Class Straight

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

public class Straight
extends Object

Represents a straight line within 2-dimensional Euclidean space.

Since:
3.6

Field Summary
 Vector direction
          direction vector of this straight
 Vector position
          position vector of this straight
 
Constructor Summary
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
 boolean contains(Vector vector)
          Calculates whether the point indicated by the provided Vector is a point on this Straight.
 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 isParallelTo(Straight other)
          Checks whether this Straight and the provided one are parallel to each other.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

position

public Vector position
position vector of this straight


direction

public Vector direction
direction vector of this straight

Constructor Detail

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 Detail

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.

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 position indicated by the given Vector is a point of this Straight, 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)

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.

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

Eclipse Draw2d
3.3

Copyright (c) IBM Corp. and others 2000, 2007. All Rights Reserved.