at.wisch.joystick.ffeffect.direction
Class CartesianDirection

java.lang.Object
  extended by at.wisch.joystick.ffeffect.direction.Direction
      extended by at.wisch.joystick.ffeffect.direction.CartesianDirection

public class CartesianDirection
extends Direction

The Class CartesianDirection. The direction is encoded by three positions: X axis, Y axis and Z axis (with 3 FF axes).

The coordinate values can be any positive or negative int value. The cardinal directions would be:
- North: {0, -1, 0}
- East: {-1, 0, 0}
- South: {0, 1, 0}
- West: {1, 0, 0}
Some other examples:
- {1, -2, 0} would be North-North-East
- {1, 2, 0) would be the same as {2, 4, 0} (coordinates define only direction, not magnitude or distance)

Author:
Martin Wischenbart

Field Summary
static int[] EAST
          The constant EAST ({1, 0, 0}): force comes from right, 3rd axis not used.
static int[] NORTH
          The constant NORTH ({0, -1, 0}): force comes from top, 3rd axis not used.
static int[] NORTHEAST
          The constant NORTHEAST ({1, -1, 0}): force comes from top-right, 3rd axis not used.
static int[] NORTHWEST
          The constant NORTHWEST ({-1, -1, 0}): force comes from top-left, 3rd axis not used.
static int[] SOUTH
          The constant SOUTH ({0, 1, 0}): force comes from bottom, 3rd axis not used.
static int[] SOUTHEAST
          The constant SOUTHEAST ({1, 1, 0}): force comes from bottom-right, 3rd axis not used.
static int[] SOUTHWEST
          The constant SOUTHWEST ({-1, 1, 0}): force comes from bottom-left, 3rd axis not used.
static int[] WEST
          The constant WEST ({-1, 0, 0}): force comes from left, 3rd axis not used.
 
Fields inherited from class at.wisch.joystick.ffeffect.direction.Direction
DIRECTION_CARTESIAN, DIRECTION_POLAR, DIRECTION_SPHERICAL
 
Constructor Summary
CartesianDirection()
          Instantiates a new cartesian direction with the default direction (NORTHWEST), 3rd axis not used.
CartesianDirection(int[] cartesianCoordinates)
          Instantiates a new cartesian direction with the specified coordinate values.
 
Method Summary
 int[] getCartesianCoordinates()
          Gets the cartesian coordinates.
 int getCartesianXCoordinate()
          Gets the cartesian X axis coordinate.
 int getCartesianYCoordinate()
          Gets the cartesian Y axis coordinate.
 int getCartesianZCoordinate()
          Gets the cartesian Z axis coordinate.
 java.lang.String getName()
          Gets the direction type as a String.
 void setCartesianCoordinates(int[] cartesianCoordinates)
          Sets the cartesian coordinates.
 void setCartesianXCoordinate(int cartesianCoordinate)
          Sets the cartesian X axis coordinate.
 void setCartesianYCoordinate(int cartesianCoordinate)
          Sets the cartesian Y axis coordinate.
 void setCartesianZCoordinate(int cartesianCoordinate)
          Sets the cartesian Z axis coordinate.
 CartesianDirection toCartesianDirection(Direction direction)
          Converts the Direction to CartesianDirection.
 PolarDirection toPolarDirection(Direction direction)
          Converts the Direction to PolarDirection.
 SphericalDirection toSphericalDirection(Direction direction)
          Converts the Direction to SphericalDirection.
 
Methods inherited from class at.wisch.joystick.ffeffect.direction.Direction
getDirectionType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH

public static final int[] NORTH
The constant NORTH ({0, -1, 0}): force comes from top, 3rd axis not used.


NORTHEAST

public static final int[] NORTHEAST
The constant NORTHEAST ({1, -1, 0}): force comes from top-right, 3rd axis not used.


EAST

public static final int[] EAST
The constant EAST ({1, 0, 0}): force comes from right, 3rd axis not used.


SOUTHEAST

public static final int[] SOUTHEAST
The constant SOUTHEAST ({1, 1, 0}): force comes from bottom-right, 3rd axis not used.


SOUTH

public static final int[] SOUTH
The constant SOUTH ({0, 1, 0}): force comes from bottom, 3rd axis not used.


SOUTHWEST

public static final int[] SOUTHWEST
The constant SOUTHWEST ({-1, 1, 0}): force comes from bottom-left, 3rd axis not used.


WEST

public static final int[] WEST
The constant WEST ({-1, 0, 0}): force comes from left, 3rd axis not used.


NORTHWEST

public static final int[] NORTHWEST
The constant NORTHWEST ({-1, -1, 0}): force comes from top-left, 3rd axis not used.

Constructor Detail

CartesianDirection

public CartesianDirection(int[] cartesianCoordinates)
Instantiates a new cartesian direction with the specified coordinate values.

Parameters:
cartesianCoordinates - the cartesian coordinates for X, Y and Z axes (an int array of size 3, any int values)

CartesianDirection

public CartesianDirection()
Instantiates a new cartesian direction with the default direction (NORTHWEST), 3rd axis not used.

Method Detail

setCartesianCoordinates

public void setCartesianCoordinates(int[] cartesianCoordinates)
Sets the cartesian coordinates.

Parameters:
cartesianCoordinates - the new cartesian coordinates for X, Y and Z axes (an int array of size 3, any int values)

setCartesianXCoordinate

public void setCartesianXCoordinate(int cartesianCoordinate)
Sets the cartesian X axis coordinate.

Parameters:
cartesianCoordinate - the new cartesian X axis coordinate (any int value)

setCartesianYCoordinate

public void setCartesianYCoordinate(int cartesianCoordinate)
Sets the cartesian Y axis coordinate.

Parameters:
cartesianCoordinate - the new cartesian Y axis coordinate (any int value)

setCartesianZCoordinate

public void setCartesianZCoordinate(int cartesianCoordinate)
Sets the cartesian Z axis coordinate.

Parameters:
cartesianCoordinate - the new cartesian Z axis coordinate (any int value)

getCartesianCoordinates

public int[] getCartesianCoordinates()
Gets the cartesian coordinates.

Returns:
the cartesian coordinates for X, Y and Z axes (an int array of size 3, any int values)

getCartesianXCoordinate

public int getCartesianXCoordinate()
Gets the cartesian X axis coordinate.

Returns:
the cartesian X axis coordinate

getCartesianYCoordinate

public int getCartesianYCoordinate()
Gets the cartesian Y axis coordinate.

Returns:
the cartesian Y axis coordinate

getCartesianZCoordinate

public int getCartesianZCoordinate()
Gets the cartesian Z axis coordinate.

Returns:
the cartesian Z axis coordinate

getName

public java.lang.String getName()
Gets the direction type as a String.

Specified by:
getName in class Direction
Returns:
the name of the direction type: "Cartesian"
See Also:
Direction.getDirectionType()

toCartesianDirection

public CartesianDirection toCartesianDirection(Direction direction)
Description copied from class: Direction
Converts the Direction to CartesianDirection. If the object already is of type CartesianDirection, it will return that object.

Specified by:
toCartesianDirection in class Direction
Parameters:
direction - the Direction to be converted
Returns:
the CartesianDirection

toPolarDirection

public PolarDirection toPolarDirection(Direction direction)
Converts the Direction to PolarDirection. If the object already is of type PolarDirection, it will return that object. The as PolarDirection supports only 2 FF axes, the third coordinate value will be ignored.

Specified by:
toPolarDirection in class Direction
Parameters:
direction - the Direction to be converted
Returns:
the PolarDirection

toSphericalDirection

public SphericalDirection toSphericalDirection(Direction direction)
Converts the Direction to SphericalDirection. If the object already is of type SphericalDirection, it will return that object.

Specified by:
toSphericalDirection in class Direction
Parameters:
direction - the Direction to be converted
Returns:
the SphericalDirection