|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.geometry.xy.XyAngle
public class XyAngle
An angular magnitude.
XyAngle only deals with angular measurement, not compass position or rotational direction. It primarily serves as an encapsulation of an abstract angle with automatic conversion between the various units - degrees, radians, etc. It also supports mathematical operations such as plus, minus, etc. that work correctly regardless of the external units used.
No public constructors are provided to minimize errors caused by specifying the wrong coordinate system. This is a bit pedantic but will hopefully prove beneficial in the long run. You may construct an XyAngle using an numeric value via one of the following factory methods:
You can then get measurements out in any of those units with automatic conversion via:
Do note that these values are not clamped (e.g. 0 <= degrees < 360) by
default, and that negative values are allowed as well as values greater than
one circle. This allows you to use XyAngle to measure e.g. multiple
rotations, spirals, etc. You can use the clampedUnsigned() method to get a
clamped version guaranteed to be non-negative and less than a circle. In
general clamping is handled by XyDirection, which clamps all angles
appropriately.
The internal representation is in 64-bit fixed point micro-seconds (actually, 1/ (1024 * 1024)). Be aware that if you HAVE to work precisely, these "microns" are probably the best choice of units - however don't write confusing code for the sake of performance or precision at the second level. Instead, work in whatever units are most natural to the problem at hand.
Copyright 2007 Partner Software, Inc.
| Method Summary | |
|---|---|
XyAngle |
clampedSigned()
Returns a clamped version of this angle whose numeric values are between positive and negative half circle. |
XyAngle |
clampedUnsigned()
Returns a clamped version of this angle - guaranteed positive and less than a complete circle. |
int |
compareTo(XyAngle nother)
|
boolean |
equals(java.lang.Object nother)
|
static XyAngle |
forDegrees(double degrees)
Returns an XyAngle with the given magnitude in degrees (1/60 circle). |
static XyAngle |
forMicrons(long microns)
Returns an XyAngle with the given magnitude in microns (1/1048576 second, 1/62914560 minute, 1/3774873600 degree, 1/1358954496000 circle). |
static XyAngle |
forMinutes(double minutes)
Returns an XyAngle with the given magnitude in minutes (1/60 degree, 1/3600 circle). |
static XyAngle |
forRadians(double radians)
Returns an XyAngle with the given magnitude in radians. |
static XyAngle |
forRevolutions(double revolutions)
Returns an XyAngle with the given magnitude in revolutions (fractional circles). |
static XyAngle |
forSeconds(double seconds)
Returns an XyAngle with the given magnitude in seconds (1/60 minute, 1/3600 degree, 1/216000 circle). |
double |
getCosine()
Returns the cosine of the angle. |
double |
getDegrees()
Returns the angle as measured in decimal degrees. |
long |
getMicrons()
Returns the angle as measured in 64-bit integer microns (1/1358954496000 circle). |
double |
getMinutes()
Returns the angle as measured in decimal minutes. |
double |
getRadians()
Returns the angle as measured in radians. |
double |
getRevolutions()
Returns the angle as measured in fractions or multiples of a circle. |
double |
getSeconds()
Returns the angle as measured in decimal seconds. |
double |
getSine()
Returns the sine of the angle. |
double |
getTangent()
Returns the tangent of the angle. |
int |
hashCode()
|
XyAngle |
inverted()
Inverts the angle. |
boolean |
isAcute()
Returns true if the angle is positive and less than half a circle. |
boolean |
isObtuse()
Returns true if the angle is greater than half a circle but less than a full circle. |
boolean |
isZero()
Returns true if this is a zero-width angle. |
XyAngle |
minus(XyAngle nother)
Subtracts the given angle from this one and gives the result. |
XyAngle |
plus(XyAngle nother)
Adds the given angle to this one and gives the result. |
XyAngle |
times(double factor)
Multiplies this angle by the given factor. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static XyAngle forRevolutions(double revolutions)
revolutions - magnitude in revolutionspublic static XyAngle forRadians(double radians)
radians - magnitude in radianspublic static XyAngle forDegrees(double degrees)
degrees - magnitude in degreespublic static XyAngle forMinutes(double minutes)
minutes - magnitude in minutespublic static XyAngle forSeconds(double seconds)
seconds - magnitude in secondspublic static XyAngle forMicrons(long microns)
XyAngle uses microns as its minimum resolution, this method requires an long to emphasize that.
microns - magnitude in micronspublic XyAngle plus(XyAngle nother)
public XyAngle minus(XyAngle nother)
public XyAngle times(double factor)
public XyAngle clampedUnsigned()
public XyAngle clampedSigned()
public XyAngle inverted()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object nother)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(XyAngle nother)
compareTo in interface java.lang.Comparable<XyAngle>public double getRevolutions()
public double getRadians()
public double getDegrees()
public double getMinutes()
public double getSeconds()
public long getMicrons()
public boolean isAcute()
public boolean isObtuse()
public boolean isZero()
public double getSine()
public double getCosine()
public double getTangent()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||