public class Angle extends Object
To construct an angle the user must consciously use RADIANS
The angle returned is always in RADIANS (except if getDegrees() is used)
If SIGNED is used, the angle is in the range -180 to 180 (-pi to pi)
If UNSIGNED is used, the angle is in the range 0 to 360 (0 to 2*pi)
Default is SIGNED
Default value of Angle is 0.0; Constructions of invalid angles should throw exceptions rather than try to make invalid angles.
| Modifier and Type | Class and Description |
|---|---|
static class |
Angle.Range
range
|
static class |
Angle.Units
units
|
| Modifier and Type | Field and Description |
|---|---|
static double |
DEGREES_IN_RADIAN |
| Constructor and Description |
|---|
Angle()
create default Angle default is (0.0)
|
Angle(Angle a)
copy constructor
|
Angle(double a)
create an angle IN RADIANS
|
Angle(double a,
Angle.Units units)
construct using degrees or radians
|
Angle(double y,
double x)
from X and Y components (uses atan2)
|
| Modifier and Type | Method and Description |
|---|---|
double |
cos()
trigonometric functions
|
double |
getAngle()
get angle in radians
|
double |
getDegrees()
get angle in degrees
|
double |
getRadian()
get angle in radians
|
Integer |
getRightAngle(Angle eps)
Tests whether this is a right angle.
|
boolean |
greaterThan(Angle a)
is one angle greater than another (after normalisation)
|
boolean |
greaterThan(double a)
is one angle greater than another (after normalisation)
|
boolean |
greaterThanOrEquals(Angle a)
is one angle greater than or equal to another (after normalisation)
|
boolean |
greaterThanOrEquals(double a)
is one angle greater than or equal to another (after normalisation)
|
boolean |
isEqualTo(Angle a)
are two angles equal
|
boolean |
isEqualTo(Angle a,
double eps)
are two angles equal
|
boolean |
isEqualTo(double a)
Deprecated.
// use epsilon method
|
boolean |
isEqualTo(double a,
double epsilon)
compare angles allowing for epsilon
|
boolean |
lessThan(Angle a)
is one angle less than another (after normalisation)
|
boolean |
lessThan(double a)
is one angle less than another (after normalisation)
|
boolean |
lessThanOrEquals(Angle a)
is one angle less than or equal to another (after normalisation)
|
boolean |
lessThanOrEquals(double a)
is one angle less than or equal to another (after normalisation)
|
Angle |
multiplyBy(double f)
multiply an angle by a scalar
|
static double |
normalise(double angle)
normalise angle.
|
void |
normalizeTo2Pi()
Normalises angle to be in range 0 -> Math.PI * 2.
|
void |
normalizeToPlusMinusPI()
normalizes angle to be in range - Math.PI -> Math.PI.
|
Angle |
plus(Angle a2)
add two angles
|
void |
putDegrees(double a) |
void |
setRange(Angle.Range range)
set type of range
|
void |
shallowCopy(Angle a)
shallowCopy
|
double |
sin()
sin of angle
|
Angle |
subtract(Angle a2)
subtract two angles
|
double |
tan()
tan.
|
String |
toString()
to string.
|
public static final double DEGREES_IN_RADIAN
public Angle()
public Angle(double a)
a - radian valuepublic Angle(double a,
Angle.Units units)
a - value of angleunits - unit of angle. It can either be in DEGREES or RADIANSpublic Angle(double y,
double x)
x - The x coordinate of the pointy - The y coordinate of the pointpublic Angle(Angle a)
a - Angle object that needs to be copiedpublic void shallowCopy(Angle a)
a - Angle object that needs to be copiedpublic Angle plus(Angle a2)
a2 - the specified angle to be added to this anglepublic Angle subtract(Angle a2)
a2 - the specified angle to be subtracted from this anglepublic Angle multiplyBy(double f)
f - a floating point scalar valuepublic double cos()
public double sin()
public double tan()
public static double normalise(double angle)
angle - the angle to be normalisedpublic void normalizeToPlusMinusPI()
public void normalizeTo2Pi()
public Integer getRightAngle(Angle eps)
eps - tolerancepublic boolean isEqualTo(double a)
a - the specified angle to which this angle is comparedpublic boolean isEqualTo(double a,
double epsilon)
a - the specified angle to which this angle is compared to be equal toepsilon - tolerance limit for equalitypublic boolean greaterThan(double a)
a - the specified angle to which this angle is compared to be greaterpublic boolean greaterThanOrEquals(double a)
a - the specified angle to which this angle is compared to be greater than or equal topublic boolean lessThan(double a)
a - the specified angle to which this angle is compared to be lesserpublic boolean lessThanOrEquals(double a)
a - the specified angle to which this angle is compared to be lesser than or equal topublic boolean isEqualTo(Angle a)
a - the specified angle to which this angle is compared to be equal topublic boolean isEqualTo(Angle a, double eps)
a - the specified angle to which this angle is compared to be equal toeps - epsilon tolerance limit for equalitypublic boolean greaterThan(Angle a)
a - the specified angle to which this angle is compared to be greater (after normalisation)public boolean greaterThanOrEquals(Angle a)
a - the specified angle to which this angle is compared to be greater than or equal to (after normalisation)public boolean lessThan(Angle a)
a - the specified angle to which this angle is compared to be lesser (after normalisation)public boolean lessThanOrEquals(Angle a)
a - the specified angle to which this angle is compared to be lesser than or equal to (after normalisation)public double getAngle()
public double getRadian()
public double getDegrees()
public void putDegrees(double a)
a - angle in degreespublic void setRange(Angle.Range range)
range - type of rangeCopyright © 1994–2024 Peter Murray-Rust. All rights reserved.