sdr 0.21

net.cscott.sdr.calls
Class Position

java.lang.Object
  extended by net.cscott.sdr.calls.Position

public class Position
extends Object

Position objects represent the position and orientation of a dancer. The (0,0) coordinate represents the center of the square (or formation), and dancers are nominally at least two units away from each other (although breathing may change this). A zero rotation for 'facing direction' means "facing the caller". Positive y is "towards the caller". Positive x is "toward the caller's left/heads' right". Dancer number one starts out at (-1, -3) facing 0. Note that the facing field MAY be null to indicate "rotation unspecified" -- for example, for phantoms or when specifying "general lines".


Field Summary
 Rotation facing
          Facing direction.
 Fraction x
          Location.
 Fraction y
          Location.
 
Constructor Summary
Position(Fraction x, Fraction y, Rotation facing)
          Create a Position object from the given x and y coordinates and Rotation.
Position(int x, int y, Rotation facing)
          Create a Position object with integer-valued x and y coordinates.
 
Method Summary
 boolean equals(Object o)
           
 Position forwardStep(Fraction distance)
          Move the given distance in the facing direction.
static Position getGrid(int x, int y, ExactRotation r)
          Returns a position corresponding to the standard square dance grid. 0,0 is the center of the set, and odd coordinates between -3 and 3 correspond to the standard 4x4 grid.
static Position getGrid(int x, int y, String direction)
          Returns a position corresponding to the standard square dance grid. 0,0 is the center of the set, and odd coordinates between -3 and 3 correspond to the standard 4x4 grid.
 int hashCode()
           
 Position normalize()
          Normalize (restrict to 0-modulus) the rotation of the given position.
 Position rotateAroundOrigin(ExactRotation rot)
          Rotate this position around the origin by the given amount.
 Position sideStep(Fraction distance)
          Move the given distance perpendicular to the facing direction.
 String toString()
           
 Position turn(Fraction amount)
          Turn in place the given amount.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public final Fraction x
Location. Always non-null.


y

public final Fraction y
Location. Always non-null.


facing

public final Rotation facing
Facing direction. Note that facing should always be an ExactRotation for real (non-phantom) dancers.

Constructor Detail

Position

public Position(Fraction x,
                Fraction y,
                Rotation facing)
Create a Position object from the given x and y coordinates and Rotation.


Position

public Position(int x,
                int y,
                Rotation facing)
Create a Position object with integer-valued x and y coordinates.

Method Detail

forwardStep

public Position forwardStep(Fraction distance)
Move the given distance in the facing direction. Requires that the facing direction be an ExactRotation.


sideStep

public Position sideStep(Fraction distance)
Move the given distance perpendicular to the facing direction. Requires that the facing direction be an ExactRotation.


turn

public Position turn(Fraction amount)
Turn in place the given amount.


rotateAroundOrigin

public Position rotateAroundOrigin(ExactRotation rot)
Rotate this position around the origin by the given amount.


normalize

public Position normalize()
Normalize (restrict to 0-modulus) the rotation of the given position.


getGrid

public static Position getGrid(int x,
                               int y,
                               ExactRotation r)
Returns a position corresponding to the standard square dance grid. 0,0 is the center of the set, and odd coordinates between -3 and 3 correspond to the standard 4x4 grid. Remember null IS a legal value for the ExactRotation.


getGrid

public static Position getGrid(int x,
                               int y,
                               String direction)
Returns a position corresponding to the standard square dance grid. 0,0 is the center of the set, and odd coordinates between -3 and 3 correspond to the standard 4x4 grid. For convenience, the direction is specified as a string valid for ExactRotation.valueOf(String).


equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

sdr 0.21

Copyright (c) 2006 C. Scott Ananian