public class Direction2D
extends java.lang.Object
implements java.lang.Cloneable
2D direction: an angle φ + corresponding unit vector (cos φ, sin φ)
This class is immutable and thread-safe: there are no ways to modify settings of the created instance.
AlgART Laboratory 2007–2014
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Creates an identical copy of this object.
|
void |
copyFrom(Direction2D other)
Sets the current direction identical to other.
|
boolean |
equals(java.lang.Object obj)
Indicates whether some other direction is equal to this one, i.e. if the angle returned by
getAngle() is the same for both directions. |
double |
getAngle()
Returns the angle: current direction is (cos φ, sin φ), φ = method result (in radians).
|
double |
getAngleBetweenDirections(Direction2D other)
Returns the shortes angle (0..π, in radians)
between the given directions.
|
static Direction2D |
getInstance()
Creates a direction (1, 0), φ = 0.
|
static Direction2D |
getInstance(double fi)
Creates a direction (cos φ, sin φ), φ = fi argument (in radians).
|
double |
getUnitVectorX()
Returns cos φ, current direction is (cos φ, sin φ).
|
double |
getUnitVectorY()
Returns sin φ, current direction is (cos φ, sin φ).
|
int |
hashCode()
Returns the hash code for this direction.
|
void |
inverse()
Rotates current direction by π: new direction angle will be φ + π,
where φ is current direction angle.
|
void |
revive()
Revive direction vector: the direction angle φ is changed to an equivalent angle in
0<=φ<2π range (if current φ is not in this range), and
the values cos φ and sin φ are recalculated.
|
void |
rotate(Rotation2D rot)
Rotates current direction: new direction angle will be φ + rot.getRotationAngle(),
where φ is current direction angle.
|
void |
rotateBack(Rotation2D rot)
Rotates current direction: new direction angle will be φ - rot.getRotationAngle(),
where φ is current direction angle.
|
void |
setAngle(double fi)
Sets the angle: new direction will be (cos φ, sin φ), φ = fi argument (in radians).
|
java.lang.String |
toString()
Returns some string representation of this object.
|
public static Direction2D getInstance()
public static Direction2D getInstance(double fi)
public void setAngle(double fi)
public double getAngle()
public double getUnitVectorX()
public double getUnitVectorY()
public double getAngleBetweenDirections(Direction2D other)
public void revive()
public void rotate(Rotation2D rot)
public void rotateBack(Rotation2D rot)
public void inverse()
public void copyFrom(Direction2D other)
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
getAngle()
is the same for both directions.
Note: if the difference between directions is 2kπ, the directions are not considered to be equal, though their unit vector are identical.
equals
in class java.lang.Object
public java.lang.Object clone()
clone
in class java.lang.Object
Установить глонасс на нашем сайте Смотрите установить глонасс на нашем сайте. trackgps.ru