java.lang.Objectjrobots.utils.Angle
public class Angle
This class represents an angle.
The angle can be given as degrees (360 are a full circle) as well as in radians (2Pi are a full circle).
A zero angle points in the right or east direction. The angle increases in clockwise direction.
Fields are immutable - the values are fixed at construction. Thus, every calculation will construct a new object.
Angle(double, String)
,
getValueAsDegrees()
,
getValueAsRadians()
,
isPositive()
,
getNegative()
,
getNextQuadrant()
,
getPreviousQuadrant()
,
getOpposite()
,
sub(Angle)
,
add(Angle)
,
mult(double)
,
normalize()
,
coneAngle(Angle, Angle)
,
angularDistance(Angle)
,
Serialized FormNested Class Summary | |
---|---|
static class |
Angle.Units
|
Field Summary | |
---|---|
double |
angle
representation in radians |
static Angle |
EAST
The angle points to the right or east. |
static Angle |
NORTH
The angle points upward or to the north. |
static Angle |
SOUTH
The angle points downward or to the south. |
static Angle |
WEST
The angle points to the left or west. |
Constructor Summary | |
---|---|
Angle()
Constructs an Angle pointing to 0 degrees. |
|
Angle(double value,
Angle.Units units)
Constructs an Angle with the given value. |
|
Angle(double value,
java.lang.String units)
Constructs an Angle with the given value. |
Method Summary | |
---|---|
Angle |
add(Angle a)
Rotates this Angle in clockwise direction |
Angle |
angularDistance(Angle a)
Calculates the angular distance of a - this. |
Angle |
clone()
|
static double |
coneAngle(Angle d1,
Angle d2)
calculates the not commutative cone angle between d1 and d2 The cone is assumed to emanate from d1 in the direction where d2 lies closest. |
Angle |
getNegative()
Results in a negated copy of this Angle Be aware that negation does not necessarily point into the opposite direction |
Angle |
getNextQuadrant()
Results in an Angle 90° in clockwise direction and normalized. |
Angle |
getOpposite()
Results in an Angle pointing to the opposite direction. |
Angle |
getPreviousQuadrant()
Results in an Angle 90° in anticlockwise direction and normalized. |
double |
getValueAsDegrees()
Gives the value of this Angle in degrees. |
double |
getValueAsRadians()
Gives the value of this Angle as radians. |
boolean |
isPositive()
There may be unnormalized Angles. |
Angle |
mult(double factor)
Multiplies this Angle by a given factor |
Angle |
normalize()
Angles in degrees smaller than zero or greater than 360° are readjusted into that range. |
Angle |
sub(Angle a)
Rotates this Angle in anticlockwise direction |
java.lang.String |
toString()
Gets a string representation in the form "Angle:1.23°" zurück. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final double angle
public static final Angle EAST
public static final Angle NORTH
public static final Angle SOUTH
public static final Angle WEST
Constructor Detail |
---|
public Angle()
public Angle(double value, Angle.Units units)
new Angle(3.14, Angle.Units.RADIANS)
new Angle(180, Angle.Units.DEGREES)
value
- - value of the angle to constructunits
- - defines how the value is to be treated (degrees or radians)public Angle(double value, java.lang.String units)
new Angle(3.14, "Radians")
new Angle(180, "Degrees")
value
- - value of the angle to constructunits
- - defines how the value is to be treated (degrees or radians)Method Detail |
---|
public Angle add(Angle a)
a
- Angle to add
public Angle angularDistance(Angle a)
a
-
public Angle clone()
clone
in class java.lang.Object
public static final double coneAngle(Angle d1, Angle d2)
The cone is assumed to emanate from d1 in the direction where d2 lies closest. A clockwise direction results in a positive angle, a anticlockwise direction in a negative angle. Opposite directions result in the Angle Pi.
Note: calculation will normalize both angles.
This method is a gift from the 2SEPS project.
d1
- d2
-
public Angle getNegative()
Be aware that negation does not necessarily point into the opposite direction
public Angle getNextQuadrant()
public Angle getOpposite()
public Angle getPreviousQuadrant()
public double getValueAsDegrees()
public double getValueAsRadians()
public boolean isPositive()
true
, if Angle > 0 false
, if Angle <= 0public Angle mult(double factor)
factor
- scaling factor
public Angle normalize()
public Angle sub(Angle a)
a
- Angle to subtract
public java.lang.String toString()
toString
in class java.lang.Object