|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.geom.YVector
public class YVector
This class represents a vector in the 2-dimensional real vector space. This vector is an ordered 2 tuple and is defined by two doubles.
Constructor Summary | |
---|---|
YVector(double dx,
double dy)
Creates a new vector with given direction. |
|
YVector(double x1,
double y1,
double x2,
double y2)
Creates a new vector, whose direction is given by two points. |
|
YVector(YPoint p1)
Creates a new vector, whose direction is given by a point. |
|
YVector(YPoint p1,
YPoint p2)
Creates a new vector, whose direction is given by two points. |
|
YVector(YVector v)
Creates a new vector which is a copy of another vector. |
Method Summary | |
---|---|
static YPoint |
add(YPoint p,
YVector v)
Adds the vector to a point and returns the resulting point. |
void |
add(YVector v)
Adds a vector to this vector. |
static YVector |
add(YVector v,
YVector w)
Adds two vectors and returns the result. |
static double |
addAngle(double a1,
double a2)
Returns the result of the addition of two angles between 0 and 2*Pi . |
static double |
angle(YVector v1,
YVector v2)
Returns the angle (measured in radians) between two vectors in clockwise order (with regards to screen coordinates) from v1 to v2. |
static YVector |
getNormal(YVector v)
Returns this vector with unit length. |
double |
getX()
Returns the first coordinate of the vector. |
double |
getY()
Returns the second coordinate of the vector. |
double |
length()
Returns the length of the vector, this is the value of the euclidean norm. |
void |
norm()
Assigns unit length to the vector. |
static YVector |
orthoNormal(YVector v)
Returns the vector which is orthogonal to the given one and has unit length. |
static boolean |
rightOf(YVector v1,
YVector v2)
Returns true if vector v1 is on the right side of v2. |
YVector |
rotate(double angle)
Returns a new YVector instance that is obtained by rotating
this vector by the given angle (measured in radians) in clockwise
direction (with regards to screen coordinates). |
static double |
scalarProduct(YVector v1,
YVector v2)
Returns the value of the scalar product of two vectors. |
void |
scale(double factor)
Scales the vector by an factor. |
java.lang.String |
toString()
Returns a string representation of this vector. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public YVector(double dx, double dy)
dx
- the first coordinatedy
- the second coordinatepublic YVector(YVector v)
v
- the vector, whose values are copied.public YVector(YPoint p1, YPoint p2)
p1
- p2
.
p1
- the first point.p2
- the second point.public YVector(YPoint p1)
p1
- (0,0).
p1
- the point.public YVector(double x1, double y1, double x2, double y2)
(x1 - x2, y1 - y2)
.
x1
- the X-coordinate of the first point.y1
- the Y-coordinate of the first point.x2
- the X-coordinate of the second point.y2
- the Y-coordinate of the second point.Method Detail |
---|
public double getX()
public double getY()
public void norm()
public YVector rotate(double angle)
YVector
instance that is obtained by rotating
this vector by the given angle (measured in radians) in clockwise
direction (with regards to screen coordinates).
Screen coordinates mean positive x-direction is from left to right and
positive y-direction is from top to bottom:
0 --> 1 | v 1
angle
- the angle of rotation in radians.
public void add(YVector v)
v
- the vector to add.public static YVector add(YVector v, YVector w)
v
- first vector to sum.w
- second vector to sum.
public static YPoint add(YPoint p, YVector v)
p
- a point.v
- the vector to add to the point.
public void scale(double factor)
factor
- the scale factor, with which the length is multiplied.public double length()
public static boolean rightOf(YVector v1, YVector v2)
public static YVector getNormal(YVector v)
public static YVector orthoNormal(YVector v)
v
- a vector.
public static double scalarProduct(YVector v1, YVector v2)
v1
- the first vector.v2
- the second vector.
v1.x * v2.x + v1.y * v2.y
public static double angle(YVector v1, YVector v2)
0 --> 1 | v 1
public static double addAngle(double a1, double a2)
0
and 2*Pi
. The result is calculated modulo 2*Pi
.
a1
- a value in [0,2Pi)
.a2
- a value in [0,2Pi)
.
2*Pi
.public java.lang.String toString()
toString
in class java.lang.Object
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |