public class Vector
extends java.lang.Object
Constructor and Description |
---|
Vector()
Initializes a new instance of the
Vector class. |
Vector(double x,
double y)
Initializes a new instance of the
Vector class. |
Vector(Vector v) |
Modifier and Type | Method and Description |
---|---|
static java.awt.geom.Point2D |
add(Vector vector,
java.awt.geom.Point2D point)
Translates point by a vector.
|
static Vector |
add(Vector vector1,
Vector vector2)
Adds two vectors.
|
static double |
angleBetween(Vector vector1,
Vector vector2)
Determines the angle between two vectors.
|
static double |
crossProduct(Vector vector1,
Vector vector2)
Returns the size of cross-product of two vectors.
|
static double |
determinant(Vector vector1,
Vector vector2)
Finds the determinant of two vectors.
|
static Vector |
divide(Vector vector,
double scalar)
Divides a vector by a scalar.
|
boolean |
equals(java.lang.Object o)
Object.equals override.
|
boolean |
equals(Vector value)
Determines if specified vector is equal to this one.
|
static boolean |
equals(Vector vector1,
Vector vector2)
Determines if two vectors are equal.
|
double |
getLength()
Gets the length of this vector.
|
double |
getLengthSquared()
Gets the squared length of this vector.
|
double |
getX()
Gets the X component of this vector.
|
double |
getY()
Gets the Y component of this vector.
|
int |
hashCode()
Object.hashCode override.
|
static Vector |
multiply(double scalar,
Vector vector)
Multiplies vector by a scalar.
|
static Vector |
multiply(Vector vector,
double scalar)
Multiplies vector by a scalar.
|
static double |
multiply(Vector vector1,
Vector vector2)
Returns the dot product of two vectors.
|
void |
negate()
Reverses the direction of this vector.
|
void |
normalize()
Makes this vector a unit vector.
|
static boolean |
notEquals(Vector vector1,
Vector vector2) |
void |
setX(double value)
Sets the X component of this vector.
|
void |
setY(double value)
Sets the Y component of this vector.
|
static Vector |
subtract(Vector vector1,
Vector vector2)
Subtracts two vectors.
|
java.lang.String |
toString()
Object.toString override.
|
java.lang.String |
toString(java.util.Locale provider)
Gets a string representation of this vector.
|
public Vector()
Vector
class.public Vector(double x, double y)
Vector
class.x
- X component of the vector.y
- Y component of the vector.public Vector(Vector v)
public static boolean equals(Vector vector1, Vector vector2)
vector1
- The first vector to compare.vector2
- The second vector to compare.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- An object to compare with this vector.public boolean equals(Vector value)
value
- The vector to compare with this one.public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.util.Locale provider)
provider
- An IFormatProvider instance.public void normalize()
public static double crossProduct(Vector vector1, Vector vector2)
vector1
- The first vector.vector2
- The second vector.public static double angleBetween(Vector vector1, Vector vector2)
vector1
- The first vector.vector2
- The second vector.public void negate()
public static Vector add(Vector vector1, Vector vector2)
vector1
- The first vector.vector2
- The second vector.public static Vector subtract(Vector vector1, Vector vector2)
vector1
- The first vector.vector2
- The second vector.public static java.awt.geom.Point2D add(Vector vector, java.awt.geom.Point2D point)
vector
- The vector to add.point
- The reference point.public static Vector multiply(Vector vector, double scalar)
vector
- The vector to multiply.scalar
- The scalar value.public static Vector multiply(double scalar, Vector vector)
scalar
- The scalar value.vector
- The vector to multiply.public static Vector divide(Vector vector, double scalar)
vector
- The vector to divide.scalar
- The scalar value.public static double multiply(Vector vector1, Vector vector2)
vector1
- The first vector.vector2
- The second vector.public static double determinant(Vector vector1, Vector vector2)
vector1
- The first vector.vector2
- The second vector.public double getX()
public void setX(double value)
public double getY()
public void setY(double value)
public double getLength()
public double getLengthSquared()