public class Vector
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static double |
TOLERANCE
Tolerance to consider two vector components equal.
|
Constructor and Description |
---|
Vector()
Constructor: a vector <0,0>.
|
Vector(double x,
double y)
Constructor: a vector
|
Vector(Vector v)
Constructor: a vector with same values as v.
|
Modifier and Type | Method and Description |
---|---|
Vector |
addVector(Vector v)
Add v's components to this vector and
return this Vector
|
double |
cos(Vector b)
Return the cosine of the angle between this and b.
|
static double |
cos(Vector a,
Vector b)
Return the cosine of the angle between a and b
|
double |
cross(Vector b)
Return the cross product of this and b.
|
static double |
cross(Vector a,
Vector b)
Return the cross product of a and b.
|
double |
distance(Vector b)
Return the distance between this vector and b.
|
static double |
distance(Vector a,
Vector b)
Return the distance between a and b.
|
double |
dot(Vector b)
Return the dot product of this Vector and b.
|
static double |
dot(Vector a,
Vector b)
Return the dot product of a and b/
|
boolean |
equals(java.lang.Object ob)
Return true iff ob is a Vector and is equal to this one.
|
double |
getX()
Return this vector's x component.
|
double |
getY()
Return this double's y component.
|
int |
hashCode()
Hashes a vector based on its components, using function Objects.hash.
|
Vector |
invert()
Invert both of this' components - change this vector to <1/x, 1/y> --
and returns this Vector.
|
double |
length()
Returns the length of this vector.
|
static double |
length(Vector a)
Return the length of a.
|
double |
magnitude()
Return the length of this vector.
|
Vector |
mult(double s)
Multiply both of this vector's components by s and
return this Vector.
|
double |
radAngle(Vector b)
Returns the angle between this and b, in radians.
|
static double |
radAngle(Vector a,
Vector b)
Return the angle between a and b, in radians.
|
Vector |
to(Vector b)
Return a new vector from this to b.
|
java.lang.String |
toString()
Return a string representation of this vector:
|
Vector |
unit()
Make this vector have length 1, with the same direction, and
Return this Vector.
|
public static final double TOLERANCE
public Vector()
public Vector(double x, double y)
public Vector(Vector v)
public double getX()
public double getY()
public Vector addVector(Vector v)
public Vector mult(double s)
public Vector invert()
public Vector unit()
public double dot(Vector b)
public static double cross(Vector a, Vector b)
public double cross(Vector b)
public static double length(Vector a)
public double length()
public double magnitude()
public double distance(Vector b)
public double cos(Vector b)
public static double radAngle(Vector a, Vector b)
public double radAngle(Vector b)
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object ob)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object