Class Vector
- java.lang.Object
-
- org.eclipse.gef.geometry.euclidean.Vector
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class Vector extends java.lang.Object implements java.lang.Cloneable, java.io.SerializableRepresents aVectorwithin 2-dimensional Euclidean space.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vectorclone()booleanequals(java.lang.Object obj)VectorgetAdded(Vector other)AnglegetAngle(Vector other)AnglegetAngleCCW(Vector other)AnglegetAngleCW(Vector other)VectorgetAveraged(Vector other)VectorgetCopy()Returns a copy of thisVectorobject.doublegetCrossProduct(Vector other)doublegetDissimilarity(Vector other)VectorgetDivided(double factor)doublegetDotProduct(Vector other)doublegetLength()Returns the length of thisVector.VectorgetMultiplied(double factor)VectorgetNormalized()VectorgetOrthogonalComplement()Returns the orthogonal complement of thisVector, which is defined to be (-y, x).VectorgetRotatedCCW(Angle angle)VectorgetRotatedCW(Angle angle)doublegetSimilarity(Vector other)Calculates the similarity of thisVectorand the provided one.VectorgetSubtracted(Vector other)inthashCode()booleanisHorizontal()Checks if thisVectoris horizontal, i.e. whether its horizontal component (the x coordinate) does not equal 0, while its vertical component (the y coordinate) does.booleanisNull()Checks if thisVector's x and y coordinates are equal to 0.booleanisOrthogonalTo(Vector other)Checks if thisVectorand the provided one are orthogonal to each other.booleanisParallelTo(Vector other)Checks if thisVectorand the provided one are parallel to each other.booleanisVertical()Checks if thisVectoris vertical, i.e. whether its vertical component (the x coordinate) does not equal 0, while its horizontal component (the y coordinate) does.VectorrotateCCW(Angle angle)VectorrotateCW(Angle angle)PointtoPoint()java.lang.StringtoString()
-
-
-
Method Detail
-
clone
public Vector clone()
- Overrides:
clonein classjava.lang.Object- Returns:
- a copy of this
Vectorobject
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(Object)
-
getCopy
public Vector getCopy()
Returns a copy of thisVectorobject.- Returns:
- a copy of this
Vectorobject
-
getCrossProduct
public double getCrossProduct(Vector other)
-
getDissimilarity
public double getDissimilarity(Vector other)
Calculates the magnitude of the cross product of thisVectorwith the given otherVector. This method normalizes bothVectors before calculating the cross product. The resulting dissimilarity value represents the amount by which twoVectors are directionally different. For parallelVectors 0 is returned.
-
getDivided
public Vector getDivided(double factor)
-
getDotProduct
public double getDotProduct(Vector other)
-
getLength
public double getLength()
Returns the length of thisVector.- Returns:
- the length of this
Vector
-
getMultiplied
public Vector getMultiplied(double factor)
-
getNormalized
public Vector getNormalized()
-
getOrthogonalComplement
public Vector getOrthogonalComplement()
Returns the orthogonal complement of thisVector, which is defined to be (-y, x).- Returns:
- the orthogonal complement of this
Vector
-
getSimilarity
public double getSimilarity(Vector other)
Calculates the similarity of thisVectorand the provided one. The similarity is defined as the absolute value of the dotProduct(). For orthogonalVectors, 0 is returned.- Parameters:
other- theVectorfor which the similarity to thisVectoris calculated- Returns:
- the similarity of this
Vectorand the provided one - See Also:
getDissimilarity(Vector)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- See Also:
Object.hashCode()
-
isHorizontal
public boolean isHorizontal()
Checks if thisVectoris horizontal, i.e. whether its horizontal component (the x coordinate) does not equal 0, while its vertical component (the y coordinate) does.
-
isNull
public boolean isNull()
Checks if thisVector's x and y coordinates are equal to 0.- Returns:
trueif thisVector's x and y coordinates are equal to 0, otherwisefalse
-
isOrthogonalTo
public boolean isOrthogonalTo(Vector other)
Checks if thisVectorand the provided one are orthogonal to each other.
-
isParallelTo
public boolean isParallelTo(Vector other)
Checks if thisVectorand the provided one are parallel to each other.
-
isVertical
public boolean isVertical()
Checks if thisVectoris vertical, i.e. whether its vertical component (the x coordinate) does not equal 0, while its horizontal component (the y coordinate) does.
-
rotateCCW
public Vector rotateCCW(Angle angle)
- Parameters:
angle- the rotationAngle- Returns:
thisfor convenience
-
rotateCW
public Vector rotateCW(Angle angle)
- Parameters:
angle- the rotationAngle- Returns:
thisfor convenience
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
-