Draw2D v2.0

org.eclipse.draw2d.geometry
Class Ray

java.lang.Object
  |
  +--org.eclipse.draw2d.geometry.Ray

public final class Ray
extends Object

Provides support for vector type calculations.


Field Summary
 int x
           
 int y
           
 
Constructor Summary
Ray()
          Constructs a Ray of no direction and magnitude.
Ray(int _x, int _y)
          Constructs a Ray with direction from the origin(0,0) to the coordinates given.
Ray(Point p)
          Constructs a Ray with direction from the origin(0,0) to the Point given.
Ray(Point start, Point end)
          Constructs a Ray which points from the first input Point to the second input Point.
Ray(Ray start, Ray end)
          Constructs a Ray which connects both the Rays given as input.
 
Method Summary
 int assimilarity(Ray r)
          Returns the cross product of this Ray and r.
 int dotProduct(Ray p)
          Returns the dot product of this Ray and p.
 Ray getAdded(Ray r)
          Returns a new Ray which is the sum of this Ray and the input Ray r.
 Ray getAveraged(Ray r)
          Returns a new Ray which points, along all axes, to the middle region of this Ray and the input Ray r.
 Ray getScaled(int s)
          Returns a new Ray which has this Ray's magnitude scaled by the value provided as input.
 boolean isHorizontal()
          Returns whether this Ray points horizontally or not.
 double length()
          Returns the length of this Ray.
 int similarity(Ray r)
          Returns the similarity of direction between this Ray and the Ray given.
 String toString()
          Returns the String description of this Ray.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public int x

y

public int y
Constructor Detail

Ray

public Ray()
Constructs a Ray of no direction and magnitude.
Since:
2.0

Ray

public Ray(int _x,
           int _y)
Constructs a Ray with direction from the origin(0,0) to the coordinates given.
Parameters:
_x - Location along X Axis.
_y - Location along Y axis.
Since:
2.0

Ray

public Ray(Point p)
Constructs a Ray with direction from the origin(0,0) to the Point given.
Parameters:
p - Point to which the ray will point from the origin.
Since:
2.0

Ray

public Ray(Point start,
           Point end)
Constructs a Ray which points from the first input Point to the second input Point.
Parameters:
start - Strarting point of the ray.
end - Ending point of the ray.
Since:
2.0

Ray

public Ray(Ray start,
           Ray end)
Constructs a Ray which connects both the Rays given as input. The direction of the Ray is from the first Ray to the second one.
Parameters:
start - Direction of the start of this Ray.
end - Direction of the end of this Ray.
Since:
2.0
Method Detail

assimilarity

public int assimilarity(Ray r)
Returns the cross product of this Ray and r. Represents the amount by which two Rays are directionally different.
Parameters:
r - Ray being compared.
Returns:
Amount by which two rays are directionally different. Parallel Rays result in a distance of zero. Perpendicular rays result in a distance of one.
Since:
2.0
See Also:
similarity(Ray)

dotProduct

public int dotProduct(Ray p)
Returns the dot product of this Ray and p.
Returns:
dot product of the two Rays.
Since:
2.0

getAdded

public Ray getAdded(Ray r)
Returns a new Ray which is the sum of this Ray and the input Ray r.
Parameters:
r - Ray to be added to this Ray.
Returns:
New Ray which is the sum of two Rays.
Since:
2.0

getAveraged

public Ray getAveraged(Ray r)
Returns a new Ray which points, along all axes, to the middle region of this Ray and the input Ray r.
Parameters:
r - Ray to calculate the average.
Returns:
New Ray which is the average of the two Rays.
Since:
2.0

getScaled

public Ray getScaled(int s)
Returns a new Ray which has this Ray's magnitude scaled by the value provided as input.
Parameters:
s - Value providing the amount to scale.
Returns:
New Ray containging the scaled values.
Since:
2.0

isHorizontal

public boolean isHorizontal()
Returns whether this Ray points horizontally or not.
Returns:
Result of the horizontal test.
Since:
2.0

length

public double length()
Returns the length of this Ray. Generally this is the distance from the point to which the Ray points to the origin.
Returns:
Length of this Ray as a double.
Since:
2.0

similarity

public int similarity(Ray r)
Returns the similarity of direction between this Ray and the Ray given. Parallel Rays return a value of one. Perpendicular Rays return a value of zero.
Parameters:
r - Ray being tested for similarity.
Returns:
Similarity result.Parallel Rays return a value of one, and perpendicular Rays give a value as zero.
Since:
2.0
See Also:
assimilarity(Ray)

toString

public String toString()
Returns the String description of this Ray.
Overrides:
toString in class Object
Returns:
The String description of this Ray.
Since:
2.0

Draw2D v2.0