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.Serializable
Represents aVector
within 2-dimensional Euclidean space.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector
clone()
boolean
equals(java.lang.Object obj)
Vector
getAdded(Vector other)
Angle
getAngle(Vector other)
Angle
getAngleCCW(Vector other)
Angle
getAngleCW(Vector other)
Vector
getAveraged(Vector other)
Vector
getCopy()
Returns a copy of thisVector
object.double
getCrossProduct(Vector other)
double
getDissimilarity(Vector other)
Vector
getDivided(double factor)
double
getDotProduct(Vector other)
double
getLength()
Returns the length of thisVector
.Vector
getMultiplied(double factor)
Vector
getNormalized()
Vector
getOrthogonalComplement()
Returns the orthogonal complement of thisVector
, which is defined to be (-y, x).Vector
getRotatedCCW(Angle angle)
Vector
getRotatedCW(Angle angle)
double
getSimilarity(Vector other)
Calculates the similarity of thisVector
and the provided one.Vector
getSubtracted(Vector other)
int
hashCode()
boolean
isHorizontal()
Checks if thisVector
is horizontal, i.e. whether its horizontal component (the x coordinate) does not equal 0, while its vertical component (the y coordinate) does.boolean
isNull()
Checks if thisVector
's x and y coordinates are equal to 0.boolean
isOrthogonalTo(Vector other)
Checks if thisVector
and the provided one are orthogonal to each other.boolean
isParallelTo(Vector other)
Checks if thisVector
and the provided one are parallel to each other.boolean
isVertical()
Checks if thisVector
is vertical, i.e. whether its vertical component (the x coordinate) does not equal 0, while its horizontal component (the y coordinate) does.Vector
rotateCCW(Angle angle)
Vector
rotateCW(Angle angle)
Point
toPoint()
java.lang.String
toString()
-
-
-
Method Detail
-
clone
public Vector clone()
- Overrides:
clone
in classjava.lang.Object
- Returns:
- a copy of this
Vector
object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(Object)
-
getCopy
public Vector getCopy()
Returns a copy of thisVector
object.- Returns:
- a copy of this
Vector
object
-
getCrossProduct
public double getCrossProduct(Vector other)
-
getDissimilarity
public double getDissimilarity(Vector other)
Calculates the magnitude of the cross product of thisVector
with the given otherVector
. This method normalizes bothVector
s before calculating the cross product. The resulting dissimilarity value represents the amount by which twoVector
s are directionally different. For parallelVector
s 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 thisVector
and the provided one. The similarity is defined as the absolute value of the dotProduct(). For orthogonalVector
s, 0 is returned.- Parameters:
other
- theVector
for which the similarity to thisVector
is calculated- Returns:
- the similarity of this
Vector
and the provided one - See Also:
getDissimilarity(Vector)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
isHorizontal
public boolean isHorizontal()
Checks if thisVector
is 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:
true
if thisVector
's x and y coordinates are equal to 0, otherwisefalse
-
isOrthogonalTo
public boolean isOrthogonalTo(Vector other)
Checks if thisVector
and the provided one are orthogonal to each other.
-
isParallelTo
public boolean isParallelTo(Vector other)
Checks if thisVector
and the provided one are parallel to each other.
-
isVertical
public boolean isVertical()
Checks if thisVector
is 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:
this
for convenience
-
rotateCW
public Vector rotateCW(Angle angle)
- Parameters:
angle
- the rotationAngle
- Returns:
this
for convenience
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
-