public class Vector extends Vector
Constructor and Description |
---|
Vector(double[] coords)
Creates a vector with the given coordinates given in an array
|
Vector(double x,
double y)
Creates a vector with the given coordinates
|
Vector(Point p)
Creates a position vector (from origo to p)
|
Vector(Point p,
Point q)
Creates a vector from point p to point q
|
Modifier and Type | Method and Description |
---|---|
Vector |
add(Vector v) |
Vector |
addThis(Point p) |
Vector |
addThis(Vector v) |
Vector |
clone()
Create a clone of this vector.
|
static Vector |
createDiff(Vector u,
Vector v) |
Vector |
createRotatedVector(double a) |
static Vector |
createSum(Vector u,
Vector v) |
static double |
crossProduct(Vector u,
Vector v) |
double |
dot(Vector v) |
static double |
dotProduct(Vector u,
Vector v) |
double[] |
getCoords() |
double |
getSlope() |
double |
getSquaredLength() |
static boolean |
leftTurn(Vector u,
Vector v) |
double |
length()
Get the length of this vector.
|
Vector |
multiply(double a)
Multiply this vector by s and return the result (without changing this object).
|
Vector |
multiplyThis(double a)
Multiply this vector by s and return the result (changing this object).
|
void |
negative() |
Vector |
normalize()
Normalize this vector and return the result (without changing this object).
|
Vector |
normalizeThis()
Normalize this vector and return the result (changing this object).
|
static boolean |
rightTurn(Vector u,
Vector v) |
Vector |
rotate90() |
Vector |
rotate90This() |
Vector |
rotateThis(double a)
Perform a counter-clock-wise rotation by a radians.
|
Vector |
scale(double a) |
Vector |
scaleToLength(double l)
Scale this vector to a certain length (returns new object and does not change this object).
|
void |
toConsole()
Writes this vector to
System.out . |
void |
toConsole(int dec)
Writes this vector to
System.out with dec decimals precision. |
Point |
toPoint()
Convert this vector to a point.
|
java.lang.String |
toString()
Returns a string-representation of this vector formatted with two decimals precision.
|
java.lang.String |
toString(int dec)
Returns a string-representation of this vector formatted with
dec decimals precision. |
double |
x() |
double |
y() |
add, addThis, angle, divide, divideThis, dot, equals, equals, get, getAngle, getCoord, getDimensions, getLengthSquared, isZeroVector, outerProduct, randomVector, scaleToLengthThis, set, setCoord, setCoords, subtract, subtractThis
public Vector(double x, double y)
public Vector(double[] coords)
public Vector(Point p)
public double x()
public double y()
public double[] getCoords()
public double getSquaredLength()
public double length()
Vector
public double getSlope()
public void negative()
public Vector scale(double a)
public Vector rotateThis(double a)
public Vector multiply(double a)
Vector
public Vector multiplyThis(double a)
Vector
multiplyThis
in class Vector
public Vector normalize()
Vector
public Vector normalizeThis()
Vector
normalizeThis
in class Vector
public Vector createRotatedVector(double a)
public Vector rotate90()
public Vector rotate90This()
public Point toPoint()
Vector
public java.lang.String toString()
Vector
public java.lang.String toString(int dec)
Vector
dec
decimals precision.public void toConsole()
Vector
System.out
.public void toConsole(int dec)
Vector
System.out
with dec
decimals precision.public Vector scaleToLength(double l)
Vector
scaleToLength
in class Vector
public double dot(Vector v)