public class Vector
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
double |
x
the X value
|
double |
y
the Y value
|
Constructor and Description |
---|
Vector(double x,
double y)
Constructs a Vector pointed in the specified direction.
|
Vector(PrecisionPoint p)
Constructs a Vector pointed in the direction specified by a Point.
|
Vector(PrecisionPoint start,
PrecisionPoint end)
Constructs a Vector representing the direction and magnitude between to
provided Points.
|
Vector(Vector start,
Vector end)
Constructs a Vector representing the difference between two provided
Vectors.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
Vector |
getAdded(Vector other)
Creates a new Vector which is the sum of this Vector with another.
|
double |
getAngle(Vector other)
Returns the angle (in degrees) between this Vector and the provided
Vector.
|
Vector |
getAveraged(Vector other)
Creates a new Vector which represents the average of this Vector with
another.
|
double |
getCrossProduct(Vector other)
Calculates the cross product of this Vector with another.
|
double |
getDissimilarity(Vector other)
Calculates the magnitude of the cross product of this Vector with
another.
|
Vector |
getDivided(double factor)
Creates a new Vector which represents this Vector divided by the provided
scalar factor.
|
double |
getDotProduct(Vector other)
Calculates the dot product of this Vector with another.
|
double |
getLength()
Returns the length of this Vector.
|
Vector |
getMultiplied(double factor)
Creates a new Vector which represents this Vector multiplied by the
provided scalar factor.
|
Vector |
getOrthogonalComplement()
Returns the orthogonal complement of this Vector, which is defined to be
(-y, x).
|
double |
getSimilarity(Vector other)
Calculates the similarity of this Vector with another.
|
Vector |
getSubtracted(Vector other)
Creates a new Vector which is the difference of this Vector with the
provided Vector.
|
int |
hashCode() |
boolean |
isHorizontal()
Checks whether this vector has a horizontal component.
|
boolean |
isNull()
Checks whether this vector equals (0,0);
|
boolean |
isOrthogonalTo(Vector other)
Calculates whether this Vector and the provided one are orthogonal to
each other.
|
boolean |
isParallelTo(Vector other)
Calculates whether this Vector and the provided one are parallel to each
other.
|
boolean |
isVertical()
Checks whether this vector has a vertical component.
|
PrecisionPoint |
toPoint()
Returns a point representation of this Vector.
|
java.lang.String |
toString() |
public Vector(double x, double y)
x
- X value.y
- Y value.public Vector(PrecisionPoint p)
p
- the pointpublic Vector(PrecisionPoint start, PrecisionPoint end)
start
- starting pointend
- End Pointpublic double getDissimilarity(Vector other)
other
- Vector being comparedpublic boolean isParallelTo(Vector other)
other
- The Vector to test for parallelismpublic double getDotProduct(Vector other)
other
- the Vector used to calculate the dot productpublic double getCrossProduct(Vector other)
other
- the Vector used to calculate the cross productpublic Vector getAdded(Vector other)
other
- Vector to be added to this Vectorpublic Vector getSubtracted(Vector other)
other
- Vector to be subtracted from this Vectorpublic double getAngle(Vector other)
other
- Vector to calculate the angle.public Vector getAveraged(Vector other)
other
- Vector to calculate the average.public Vector getMultiplied(double factor)
factor
- Value providing the amount to scale.public Vector getDivided(double factor)
factor
- Value providing the amount to scale.public Vector getOrthogonalComplement()
public double getLength()
public double getSimilarity(Vector other)
other
- Vector being tested for similaritygetDissimilarity(Vector)
public boolean isOrthogonalTo(Vector other)
other
- Vector being tested for orthogonalitypublic boolean isHorizontal()
public boolean isVertical()
public boolean isNull()
public PrecisionPoint toPoint()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Object.equals(Object)
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.