at.wisch.joystick.ffeffect.direction
Class SphericalDirection

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

public class SphericalDirection
extends Direction

The Class SphericalDirection. Similar to PolarDirection, a SphericalDirection is encoded by two rotations:
1) Degrees from (1, 0) rotated towards (0, 1).
2) Degrees towards (0, 0, 1) (device needs to have 3 FF axes).

Example: A direction of 27000 for the first angle and 4500 for the second would be directly away from the user (270 degrees clockwise from east) and angling toward the floor (45 degrees downward from the tabletop). To counteract a force with this direction, the user would have to push forward and down.

The degree values are encoded by hundredths of a degree. The cardinal directions would be:
- East: {0, 0}
- South: {9000, 0}
- West: {18000, 0}
- North: {27000, 0}

Author:
Martin Wischenbart

Field Summary
static int[] EAST
          The constant EAST ({0, 0}): force comes from right, 3rd axis not used.
static int[] NORTH
          The constant NORTH ({27000, 0}): force comes from top, 3rd axis not used.
static int[] NORTHEAST
          The constant NORTHEAST ({31500, 0}): force comes from top-right, 3rd axis not used.
static int[] NORTHWEST
          The constant NORTHWEST ({22500, 0}): force comes from top-left, 3rd axis not used.
static int[] SOUTH
          The constant SOUTH ({9000, 0}): force comes from bottom, 3rd axis not used.
static int[] SOUTHEAST
          The constant SOUTHEAST ({4500, 0}): force comes from bottom-right, 3rd axis not used.
static int[] SOUTHWEST
          The constant SOUTHWEST ({13500, 0}): force comes from bottom-left, 3rd axis not used.
static int[] WEST
          The constant WEST ({18000, 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
SphericalDirection()
          Instantiates a new spherical direction with the default direction (NORTHWEST), 3rd axis not used.
SphericalDirection(int[] sphericalCoordinates)
          Instantiates a new spherical direction with the specified coordinate values.
 
Method Summary
 java.lang.String getName()
          Gets the direction type as a String.
 int[] getSphericalCoordinates()
          Gets the spherical coordinate values.
 void setSphericalCoordinates(int[] sphericalCoordinates)
          Sets the spherical coordinate values.
 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 ({27000, 0}): force comes from top, 3rd axis not used.


NORTHEAST

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


EAST

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


SOUTHEAST

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


SOUTH

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


SOUTHWEST

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


WEST

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


NORTHWEST

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

Constructor Detail

SphericalDirection

public SphericalDirection(int[] sphericalCoordinates)
Instantiates a new spherical direction with the specified coordinate values.

Parameters:
sphericalCoordinates - the spherical coordinates (an int array of size 2, values from 0 to 35999)

SphericalDirection

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

Method Detail

getSphericalCoordinates

public int[] getSphericalCoordinates()
Gets the spherical coordinate values.

Returns:
the spherical coordinates (an int array of size 2, values from 0 to 35999)

setSphericalCoordinates

public void setSphericalCoordinates(int[] sphericalCoordinates)
Sets the spherical coordinate values.

Parameters:
sphericalCoordinates - the new spherical coordinates (an int array of size 2, values from 0 to 35999)

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: "Spherical"
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 second angle 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. As the Direction is a SphericalDirection it returns this (not a copy, but really this object)

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