public class MathVector extends Object
Constructor and Description |
---|
MathVector()
creates a new vector with both coordinates 0
|
MathVector(double x1,
double y1)
creates a new vector (x1, y1)
|
MathVector(double x1,
double y1,
double x2,
double y2)
creates a new vector with x-coordinate x2-x1 and y-coordinate y2-y1
|
Modifier and Type | Method and Description |
---|---|
void |
add(MathVector other)
adds the param-vector to the vector
|
Object |
clone()
clones the object
|
boolean |
equals(MathVector other)
tests if the vectors are the same point with a tolerance
of 1 in each coordinate
|
double |
getAngle()
Returns the angle between the vector and the vector (1, 0)
|
int |
getDirectionQuadrant()
returns the number of quadrant
1: 0� - 90�
2: 90�- 180�
3: 180� - 270�
4: 270� - 360�
|
double |
getLength()
return the length of the vector
|
int |
getPreciseDirectionQuadrant()
returns the number of quadrant
1: 0� - 90�
2: 90�- 180�
3: 180� - 270�
4: 270� - 360�
or the number of the axis section
5: x positive
6: y positive
7: x negative
8: y negative
9: 0 vector
|
double |
getX()
returns the x-coordinate
|
double |
getY()
returns the y-coordinate
|
void |
inverseDirection()
inverse the direction of the vector
|
void |
rotate90deg()
rotates the vector by 90 degree counterclockwise
y -> x, -x -> y
|
double |
scalarProduct(MathVector other)
calculates the scalar product of both vectors
|
void |
setDirection(MathVector vector)
set the direction of the vector to the direction of the param-vector
|
void |
setLength(double length)
set the length of the vector to the given value
|
void |
setLengthToTen()
set the length of the vector to ten
[not to one to lose not too much precission
|
void |
setX(double x)
set the x-coordinate
|
void |
setY(double y)
set the y-coordinate
|
void |
sub(MathVector other)
subtract the other vector
|
public MathVector()
public MathVector(double x1, double y1, double x2, double y2)
x1
- x-coordinate of root pointy1
- y-coordinate of root pointx2
- x-coordinate of top pointy2
- y-coordinate of top pointpublic MathVector(double x1, double y1)
x1
- x-coordinate of the vectory1
- y-coordinate of the vectorpublic double getX()
public double getY()
public void setX(double x)
x
- x-coordinatepublic void setY(double y)
public double getLength()
public void setLengthToTen()
public void setDirection(MathVector vector)
vector
- directionpublic void rotate90deg()
public void setLength(double length)
length
- new lenghtpublic Object clone()
public void add(MathVector other)
other
- vector to addedpublic double getAngle()
public int getDirectionQuadrant()
public int getPreciseDirectionQuadrant()
public void inverseDirection()
public void sub(MathVector other)
other
- vector to subtractpublic boolean equals(MathVector other)
other
- other vectorpublic double scalarProduct(MathVector other)
other
- vector