physics3d
Class Angle

java.lang.Object
  extended by physics3d.Angle
All Implemented Interfaces:
Serializable, Comparable

public final class Angle
extends Object
implements Serializable, Comparable

Angle is an immutable abstract data type which represents the mathematical notion of an angle. Angle represents a non-negative angle less than 360 degrees or 2*pi radians.

See Also:
Serialized Form

Field Summary
static Angle DEG_135
          A 135-degree angle
static Angle DEG_180
          A 180-degree angle
static Angle DEG_225
          A 225-degree angle
static Angle DEG_270
          A 270-degree angle
static Angle DEG_315
          A 315-degree angle
static Angle DEG_45
          A 45-degree angle
static Angle DEG_90
          A 90-degree angle
static Angle RAD_PI
          An angle of pi radians
static Angle RAD_PI_OVER_FOUR
          An angle of pi/4 radians
static Angle RAD_PI_OVER_TWO
          An angle of pi/2 radians
static Angle ZERO
          A zero-degree or zero-radian angle
 
Constructor Summary
Angle(double radians)
           
Angle(double x, double y)
           
 
Method Summary
 int compareTo(Angle c)
          Compares this object with the specified object for order.
 int compareTo(Object o)
          Compares this object with the specified object for order.
 double cos()
           
 double degrees()
           
 boolean equals(Angle a)
           
 boolean equals(Object o)
           
 int hashCode()
           
 Angle minus(Angle a)
           
 Angle plus(Angle a)
           
 double radians()
           
 double sin()
           
 double tan()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final Angle ZERO
A zero-degree or zero-radian angle


DEG_45

public static final Angle DEG_45
A 45-degree angle


DEG_90

public static final Angle DEG_90
A 90-degree angle


DEG_135

public static final Angle DEG_135
A 135-degree angle


DEG_180

public static final Angle DEG_180
A 180-degree angle


DEG_225

public static final Angle DEG_225
A 225-degree angle


DEG_270

public static final Angle DEG_270
A 270-degree angle


DEG_315

public static final Angle DEG_315
A 315-degree angle


RAD_PI_OVER_FOUR

public static final Angle RAD_PI_OVER_FOUR
An angle of pi/4 radians


RAD_PI_OVER_TWO

public static final Angle RAD_PI_OVER_TWO
An angle of pi/2 radians


RAD_PI

public static final Angle RAD_PI
An angle of pi radians

Constructor Detail

Angle

public Angle(double radians)
Effects:
constructs an Angle with radians radians.

Angle

public Angle(double x,
             double y)
Requires:
(x,y) != (0,0)
Effects:
constructs the Angle that is formed between the positive x-axis and the line from the origin to (x, y).
Method Detail

cos

public double cos()
Returns:
the cosine of this.

sin

public double sin()
Returns:
the sine of this.

tan

public double tan()
Returns:
the tangent of this.

radians

public double radians()
Returns:
the number of radians represented by this in the range of -pi to pi.

degrees

public double degrees()
Returns:
the number of degrees represented by this in the range of -180 to 180

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order.

Specified by:
compareTo in interface Comparable
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if o is not an Angle
NullPointerException - if o is null

compareTo

public int compareTo(Angle c)
Compares this object with the specified object for order.

Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
NullPointerException - if c is null

plus

public Angle plus(Angle a)
Returns:
the angle this + a.
Requires:
a is not null

minus

public Angle minus(Angle a)
Returns:
the angle this - a.
Requires:
a is not null

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Angle a)

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object