Renderer
Class Position

java.lang.Object
  |
  +--Renderer.Position

public class Position
extends java.lang.Object

Defines a position (x, y, and z) and provides a rich set of methods to manipulate it.

Version:
Created 17 February 2003
Author:
Dan Tappan

Field Summary
static int NORMALIZE_CLAMP
           
 int normalize_mode
           
static int NORMALIZE_NONE
           
static int NORMALIZE_WRAP
           
 float x
           
 float x_max
           
 float x_min
           
 float x_nominal
           
 float x_step
           
 float y
           
 float y_max
           
 float y_min
           
 float y_nominal
           
 float y_step
           
 float z
           
 float z_max
           
 float z_min
           
 float z_nominal
           
 float z_step
           
 
Constructor Summary
Position()
          Creates a position with all nominal values.
Position(float x, float y, float z)
          Creates a position with both nominal values and the given values.
Position(float x_min, float x_max, float x_nominal, float x_step, float y_min, float y_max, float y_nominal, float y_step, float z_min, float z_max, float z_nominal, float z_step)
          Creates a position with the given values.
Position(Position position)
          Creates a position with both nominal values and the given values.
 
Method Summary
 void add(Position position)
          Adds two positions and normalizes the result according to normalize_mode.
 void clamp()
          Limits x, y, and z to the range specified in their *_min and *_max values.
 Position divide(int divisor)
          Returns a position with x, y, and z divided.
 Position getClone()
          Returns a clone of this object.
 float getDistance(Position position)
          Returns the Euclidean distance between two positions.
 javax.vecmath.Vector3d getVector()
          Returns a Vector3d representation of the position ordered as (x,y,z).
 boolean isEqual(Position position, float tolerance)
          Returns whether two positions are equal within a tolerance.
 void moveBackward()
          Adjusts z backward according to z_step and normalizes it according to normalize_mode.
 void moveDown()
          Adjusts y downward according to y_step and normalizes it according to normalize_mode.
 void moveForward()
          Adjusts z forward according to z_step and normalizes it according to normalize_mode.
 void moveLeft()
          Adjusts x leftward according to x_step and normalizes it according to normalize_mode.
 void moveRight()
          Adjusts x rightward according to x_step and normalizes it according to normalize_mode.
 void moveUp()
          Adjusts y upward according to y_step and normalizes it according to normalize_mode.
 void normalize()
          Normalizes x, y, and z according to normalize_mode.
 void reset()
          Resets x, y, and z to their nominal values x_nominal, y_nominal, and z_nominal, respectively, and normalizes them according to normalize_mode.
 void set(float x, float y, float z)
          Sets the position and normalizes it according to normalize_mode.
 void set(Position position)
          Sets the position and normalizes it according to normalize_mode.
 void subtract(Position position)
          Subtracts two positions and normalizes the result according to normalize_mode.
 java.lang.String toString()
          Returns a string representation of this object.
 void wrap()
          Wraps x, y, and z around the range specified in their *_min and *_max values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMALIZE_NONE

public static final int NORMALIZE_NONE
See Also:
Constant Field Values

NORMALIZE_WRAP

public static final int NORMALIZE_WRAP
See Also:
Constant Field Values

NORMALIZE_CLAMP

public static final int NORMALIZE_CLAMP
See Also:
Constant Field Values

normalize_mode

public int normalize_mode

x

public float x

x_min

public float x_min

x_max

public float x_max

x_nominal

public float x_nominal

x_step

public float x_step

y

public float y

y_min

public float y_min

y_max

public float y_max

y_nominal

public float y_nominal

y_step

public float y_step

z

public float z

z_min

public float z_min

z_max

public float z_max

z_nominal

public float z_nominal

z_step

public float z_step
Constructor Detail

Position

public Position()
Creates a position with all nominal values.


Position

public Position(float x,
                float y,
                float z)
Creates a position with both nominal values and the given values.

Parameters:
x - - the x component
y - - the y component
z - - the z component

Position

public Position(Position position)
Creates a position with both nominal values and the given values.

Parameters:
position - - the position

Position

public Position(float x_min,
                float x_max,
                float x_nominal,
                float x_step,
                float y_min,
                float y_max,
                float y_nominal,
                float y_step,
                float z_min,
                float z_max,
                float z_nominal,
                float z_step)
Creates a position with the given values.

Parameters:
x_min - - the minimum x
x_max - - the maximum x
x_nominal - - the nominal x
x_step - - the change in x induced by moveLeft() and moveRight()
y_min - - the minimum y
y_max - - the maximum y
y_nominal - - the nominal y
y_step - - the change in y induced by moveUp() and moveDown()
z_min - - the minimum z
z_max - - the maximum z
z_nominal - - the nominal z
z_step - - the change in z induced by moveForward() and moveBackward()
Method Detail

add

public void add(Position position)
Adds two positions and normalizes the result according to normalize_mode.

Parameters:
position - - the addend

clamp

public void clamp()
Limits x, y, and z to the range specified in their *_min and *_max values.


divide

public Position divide(int divisor)
Returns a position with x, y, and z divided.

Parameters:
divisor - - the divisor
Returns:
the divided position

getClone

public Position getClone()
Returns a clone of this object.

Returns:
the clone

getDistance

public float getDistance(Position position)
Returns the Euclidean distance between two positions.

Parameters:
position - - the position
Returns:
the distance

getVector

public javax.vecmath.Vector3d getVector()
Returns a Vector3d representation of the position ordered as (x,y,z).

Returns:
the vector

isEqual

public boolean isEqual(Position position,
                       float tolerance)
Returns whether two positions are equal within a tolerance. Only their x, y, and z components are compared.

Parameters:
position - - the position to check
tolerance - - the proximity tolerance for comparison
Returns:
the outcome

moveBackward

public void moveBackward()
Adjusts z backward according to z_step and normalizes it according to normalize_mode.


moveDown

public void moveDown()
Adjusts y downward according to y_step and normalizes it according to normalize_mode.


moveForward

public void moveForward()
Adjusts z forward according to z_step and normalizes it according to normalize_mode.


moveLeft

public void moveLeft()
Adjusts x leftward according to x_step and normalizes it according to normalize_mode.


moveRight

public void moveRight()
Adjusts x rightward according to x_step and normalizes it according to normalize_mode.


moveUp

public void moveUp()
Adjusts y upward according to y_step and normalizes it according to normalize_mode.


normalize

public void normalize()
Normalizes x, y, and z according to normalize_mode.


reset

public void reset()
Resets x, y, and z to their nominal values x_nominal, y_nominal, and z_nominal, respectively, and normalizes them according to normalize_mode.


set

public void set(Position position)
Sets the position and normalizes it according to normalize_mode.

Parameters:
position - - the position

set

public void set(float x,
                float y,
                float z)
Sets the position and normalizes it according to normalize_mode.

Parameters:
x - - the x component
y - - the y component
z - - the z component

subtract

public void subtract(Position position)
Subtracts two positions and normalizes the result according to normalize_mode.

Parameters:
position - - the subtrahend

wrap

public void wrap()
Wraps x, y, and z around the range specified in their *_min and *_max values.


toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the String representation
See Also:
Support.toPrettyString(java.lang.String)