|
sdr 0.21 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.cscott.sdr.calls.Rotation
public class Rotation
Rotations are represented as fractions, where '0' is facing north, and '1/4' is facing east. The also have a 'modulus', since they can represent "general" directions. For example, "1/4 modulo 1/2" means facing east or west (but not north, south, or any other direction). A rotation modulo 0 matches any direction. A rotation modulo 1 indicates an 'exact' rotation; the modulus can not exceed 1.
Field Summary | |
---|---|
Fraction |
amount
The amount of the rotation. |
Fraction |
modulus
The 'modulus' of the rotation: indicates the amount of uncertainty in the direction. |
Constructor Summary | |
---|---|
protected |
Rotation(Fraction amount,
Fraction modulo)
Private constructor from a Fraction object. |
Method Summary | |
---|---|
Rotation |
add(Fraction f)
Add the given amount to this rotation direction. |
static Rotation |
create(Fraction amount,
Fraction modulo)
|
boolean |
equals(Object o)
Rotations are equal iff their normalized rotation amount and modulus are exactly equal. |
static Rotation |
fromAbsoluteString(String s)
Converts a string (one of n/s/e/w, ne/nw/se/sw) to the appropriate rotation object. |
int |
hashCode()
Hashcode of the normalized amount & modulus. |
boolean |
includes(Rotation r)
Returns true iff all the rotations possible with the given r
are included within the set of rotations possible with this . |
boolean |
isExact()
Return true iff this rotation is exact (that is, if the modulus is one). |
Rotation |
negate()
Negate this rotation (mirror image). |
Rotation |
normalize()
Normalize rotation to the range 0-modulus. |
Rotation |
subtract(Fraction f)
Subtract the given amount from this rotation direction. |
String |
toAbsoluteString()
Returns a human-readable description of the rotation, similar to the input to ExactRotation.fromAbsoluteString(String) . |
String |
toString()
Returns a human-readable description of the rotation. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public final Fraction amount
public final Fraction modulus
Constructor Detail |
---|
protected Rotation(Fraction amount, Fraction modulo)
Fraction
object.
Method Detail |
---|
public static final Rotation create(Fraction amount, Fraction modulo)
public boolean isExact()
public Rotation add(Fraction f)
public Rotation subtract(Fraction f)
public Rotation negate()
public Rotation normalize()
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public boolean includes(Rotation r)
r
are included within the set of rotations possible with this
.
For example, the Rotation 0 mod 1/4
(ie, north, east, south, or
west, but no intermediate directions) includes 3/4 mod 1
(ie, exactly west), but the reverse is not true: 3/4 mod 1
includes 7/4 mod 1
, but does not include 0 mod 1/4
.
Formally, returns true iff the congruence class of this
is
a superset of the congruence class of r
.
public String toString()
ExactRotation.valueOf(String)
.
toString
in class Object
public String toAbsoluteString()
ExactRotation.fromAbsoluteString(String)
.
public static Rotation fromAbsoluteString(String s)
|
sdr 0.21 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |