Package org.eclipse.draw2d.geometry
Class Vector
java.lang.Object
org.eclipse.draw2d.geometry.Vector
Represents a vector within 2-dimensional Euclidean space.
- Since:
- 3.6
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionVector(double x, double y) Constructs a Vector pointed in the specified direction.Constructs a Vector pointed in the direction specified by a Point.Constructs a Vector representing the direction and magnitude between to provided Points.Constructs a Vector pointed in the direction specified by a PrecisionPoint.Vector(PrecisionPoint start, PrecisionPoint end) Constructs a Vector representing the direction and magnitude between to provided PrecisionPoint.Constructs a Vector representing the difference between two provided Vectors.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanCreates a new Vector which is the sum of this Vector with another.doubleReturns the angle (in degrees) between this Vector and the provided Vector.getAveraged(Vector other) Creates a new Vector which represents the average of this Vector with another.doublegetCrossProduct(Vector other) Calculates the cross product of this Vector with another.doublegetDissimilarity(Vector other) Calculates the magnitude of the cross product of this Vector with another.getDivided(double factor) Creates a new Vector which represents this Vector divided by the provided scalar factor.doublegetDotProduct(Vector other) Calculates the dot product of this Vector with another.doubleReturns the length of this Vector.getMultiplied(double factor) Creates a new Vector which represents this Vector multiplied by the provided scalar factor.Returns the orthogonal complement of this Vector, which is defined to be (-y, x).doublegetSimilarity(Vector other) Calculates the similarity of this Vector with another.getSubtracted(Vector other) Creates a new Vector which is the difference of this Vector with the provided Vector.inthashCode()booleanChecks whether this vector has a horizontal component.booleanisNull()Checks whether this vector equals (0,0);booleanisOrthogonalTo(Vector other) Calculates whether this Vector and the provided one are orthogonal to each other.booleanisParallelTo(Vector other) Calculates whether this Vector and the provided one are parallel to each other.booleanChecks whether this vector has a vertical component.toPoint()Returns a point representation of this Vector.toString()
- 
Field Details- 
xpublic double xthe X value
- 
ypublic double ythe Y value
 
- 
- 
Constructor Details- 
Vectorpublic Vector(double x, double y) Constructs a Vector pointed in the specified direction.- Parameters:
- x- X value.
- y- Y value.
 
- 
VectorConstructs a Vector pointed in the direction specified by a PrecisionPoint.- Parameters:
- p- the point
 
- 
VectorConstructs a Vector pointed in the direction specified by a Point.- Parameters:
- p- the point
- Since:
- 3.18
 
- 
VectorConstructs a Vector representing the direction and magnitude between to provided PrecisionPoint.- Parameters:
- start- starting point
- end- End Point
 
- 
VectorConstructs a Vector representing the direction and magnitude between to provided Points.- Parameters:
- start- starting point
- end- End Point
- Since:
- 3.18
 
- 
VectorConstructs a Vector representing the difference between two provided Vectors.- Parameters:
- start- The start Ray
- end- The end Ray
 
 
- 
- 
Method Details- 
getDissimilarityCalculates the magnitude of the cross product of this Vector with another. Represents the amount by which two Vectors are directionally different. Parallel Vectors return a value of 0.- Parameters:
- other- Vector being compared
- Returns:
- The dissimilarity
 
- 
isParallelToCalculates whether this Vector and the provided one are parallel to each other.- Parameters:
- other- The Vector to test for parallelism
- Returns:
- true if this Vector and the provided one are parallel, false otherwise.
 
- 
getDotProductCalculates the dot product of this Vector with another.- Parameters:
- other- the Vector used to calculate the dot product
- Returns:
- The dot product
 
- 
getCrossProductCalculates the cross product of this Vector with another.- Parameters:
- other- the Vector used to calculate the cross product
- Returns:
- The cross product.
 
- 
getAddedCreates a new Vector which is the sum of this Vector with another.- Parameters:
- other- Vector to be added to this Vector
- Returns:
- a new Vector representing the sum
 
- 
getSubtractedCreates a new Vector which is the difference of this Vector with the provided Vector.- Parameters:
- other- Vector to be subtracted from this Vector
- Returns:
- a new Vector representing the difference.
 
- 
getAngleReturns the angle (in degrees) between this Vector and the provided Vector.- Parameters:
- other- Vector to calculate the angle.
- Returns:
- the angle between the two Vectors in degrees.
 
- 
getAveragedCreates a new Vector which represents the average of this Vector with another.- Parameters:
- other- Vector to calculate the average.
- Returns:
- a new Vector
 
- 
getMultipliedCreates a new Vector which represents this Vector multiplied by the provided scalar factor.- Parameters:
- factor- Value providing the amount to scale.
- Returns:
- a new Vector
 
- 
getDividedCreates a new Vector which represents this Vector divided by the provided scalar factor.- Parameters:
- factor- Value providing the amount to scale.
- Returns:
- a new Vector
 
- 
getOrthogonalComplementReturns the orthogonal complement of this Vector, which is defined to be (-y, x).- Returns:
- the orthogonal complement of this Vector
 
- 
getLengthpublic double getLength()Returns the length of this Vector.- Returns:
- Length of this Vector
 
- 
getSimilarityCalculates the similarity of this Vector with another. Similarity is defined as the absolute value of the dotProduct(). Orthogonal vectors return a value of 0.- Parameters:
- other- Vector being tested for similarity
- Returns:
- the Similarity
- See Also:
 
- 
isOrthogonalToCalculates whether this Vector and the provided one are orthogonal to each other.- Parameters:
- other- Vector being tested for orthogonality
- Returns:
- true, if this Vector and the provide one are orthogonal, false otherwise
 
- 
isHorizontalpublic boolean isHorizontal()Checks whether this vector has a horizontal component.- Returns:
- true if x != 0, false otherwise.
 
- 
isVerticalpublic boolean isVertical()Checks whether this vector has a vertical component.- Returns:
- true if y != 0, false otherwise.
 
- 
isNullpublic boolean isNull()Checks whether this vector equals (0,0);- Returns:
- true if x == 0 and y == 0.
 
- 
toPointReturns a point representation of this Vector.- Returns:
- a PrecisionPoint representation
 
- 
toString
- 
equals
- 
hashCodepublic int hashCode()
 
-