com.tensegrity.composite.coordinate
Class CoordinateSystem

java.lang.Object
  extended bycom.tensegrity.composite.coordinate.CoordinateSystem
Direct Known Subclasses:
MutableCoordinateSystem

public class CoordinateSystem
extends java.lang.Object

The modern Cartesian coordinate system in two dimensions (also called a rectangular coordinate system) is commonly defined by two axes, at right angles to each other, forming an xy plane. These axes are measured using a Scale for each dimension: one for the x-axis and one for the y-axis (or one for the degree and one for the radius when using polar-coordinates).

In a three-dimensional coordinate system, another axis is added to provide a third dimension of spatial measurement. These axes are commonly defined as being mutually orthogonal to each other. Many other coordinate systems have been developed since the time of Descartes. One is the aforementioned polar-coordinate system. Astronomers, for example, often use spherical coordinates, a type of polar coordinate system.

To avoid creating identical CoordinateSystem objects (using the same Scale types and intervals), objects are pooled in the CoordinateSystemPool singleton. Since many clients may have a reference to the very same instance, CoordinateSystem objects are immutable. A mutable version is defined by the MutableCoordinateSystem interface.

In a graphical context, every object must lie within a coordinate system. Very often, you have a complex situation where coordinate systems are nested. This class can therefore convert coordinates from an outer coordinate system to an inner coordinate system and vice versa.

This class uses and depends on the Scale interface.

This framework does not support polar coordinates at this time.

Version:
$Id: CoordinateSystem.java,v 1.21 2005/05/20 15:41:02 AndreasEbbert Exp $
Author:
MichaelKegel

Field Summary
static CoordinateSystem DEFAULT_SYSTEM
          A default coordinate-system with minimum and maximum values set to zero.
static int SCALE_X
          Constant that tells about which direction is meant
static int SCALE_Y
          Constant that tells about which direction is meant
static int SCALE_Z
          Constant that tells about which direction is meant
protected  Scale[] scales
          Array of scales used for the coordinate system
 
Method Summary
 double descale(int direction, double minimum, double maximum, double valueToDescale)
          Converts the value given by valueToDescale to the range given by minimum and maximum to the range Scale in the given direction.
 boolean equals(java.lang.Object obj)
           
 java.lang.String getCanonicalDescription()
          Returns the canonical description of this coordinate system instance
 double getScaleMaximum(int direction)
          Returns the maximal-value of the scale in the given direction.
 double getScaleMinimum(int direction)
          Returns the minimal-value of the scale in the given direction.
 double getScaleRange(int direction)
          Returns the set range for the scale in the given direction.
 Transform2D getTransform2D_inverse(double minimumX, double maximumX, double minimumY, double maximumY)
          Returns the inverse Transform2D resulting from the given min and max values (defining a bounding-box) and the scalefactors used by the Scales of this CoordinateSystem.
 Transform2D getTransform2D(double minimumX, double maximumX, double minimumY, double maximumY)
          Returns the Transform2D resulting from the given min and max values (defining a bounding-box) and the scalefactors used by the Scales of this CoordinateSystem.
 int hashCode()
           
 double scale(int direction, double minimum, double maximum, double valueToScale)
          Converts the value given by valueToScale from the range of the Scale in the given direction to the range given by minimum and maximum.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SYSTEM

public static final CoordinateSystem DEFAULT_SYSTEM
A default coordinate-system with minimum and maximum values set to zero.


SCALE_X

public static final int SCALE_X
Constant that tells about which direction is meant

See Also:
Constant Field Values

SCALE_Y

public static final int SCALE_Y
Constant that tells about which direction is meant

See Also:
Constant Field Values

SCALE_Z

public static final int SCALE_Z
Constant that tells about which direction is meant

See Also:
Constant Field Values

scales

protected Scale[] scales
Array of scales used for the coordinate system

Method Detail

getScaleMinimum

public double getScaleMinimum(int direction)
Returns the minimal-value of the scale in the given direction.

Parameters:
direction - the direction to return the scale minimum for.
Returns:
the minimal-value of the scale in the given direction.

getScaleMaximum

public double getScaleMaximum(int direction)
Returns the maximal-value of the scale in the given direction.

Parameters:
direction - the direction to return the scale minimum for.
Returns:
the maximal-value of the scale in the given direction.

getScaleRange

public double getScaleRange(int direction)
Returns the set range for the scale in the given direction.

Parameters:
direction - the direction to return the scale range for.
Returns:
the set range for the scale in the given direction.

scale

public double scale(int direction,
                    double minimum,
                    double maximum,
                    double valueToScale)
Converts the value given by valueToScale from the range of the Scale in the given direction to the range given by minimum and maximum.

Parameters:
direction - the direction in which to scale. Valid values are SCALE_X, SCALE_Y and SCALE_Z.
minimum - the minimum value of the range to convert to.
maximum - the maximum value of the range to convert to.
valueToScale - the value to convert.
Returns:
double the scaled value.
See Also:
Scale.scale(double, double, double)

Find more information in the class documentation


descale

public double descale(int direction,
                      double minimum,
                      double maximum,
                      double valueToDescale)
Converts the value given by valueToDescale to the range given by minimum and maximum to the range Scale in the given direction.

Parameters:
direction - the direction in which to scale. Valid values are SCALE_X, SCALE_Y and SCALE_Z.
minimum - the minimum value of the range to convert from.
maximum - the maximum value of the range to convert from.
valueToDescale - the value to convert.
Returns:
double the converted value.
See Also:
Scale.descale(double, double, double)

Find more information in the class documentation


getTransform2D

public Transform2D getTransform2D(double minimumX,
                                  double maximumX,
                                  double minimumY,
                                  double maximumY)
Returns the Transform2D resulting from the given min and max values (defining a bounding-box) and the scalefactors used by the Scales of this CoordinateSystem.

Parameters:
minimumX - minimum in x-direction.
maximumX - maximum in x-direction.
minimumY - minimum in y-direction.
maximumY - maximum in y-direction.
Returns:
the resulting Transform2D.

Find more information in the class documentation


getTransform2D_inverse

public Transform2D getTransform2D_inverse(double minimumX,
                                          double maximumX,
                                          double minimumY,
                                          double maximumY)
Returns the inverse Transform2D resulting from the given min and max values (defining a bounding-box) and the scalefactors used by the Scales of this CoordinateSystem.

Parameters:
minimumX - minimum in x-direction.
maximumX - maximum in x-direction.
minimumY - minimum in y-direction.
maximumY - maximum in y-direction.
Returns:
the resulting Transform2D.

Find more information in the class documentation


toString

public java.lang.String toString()

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

getCanonicalDescription

public java.lang.String getCanonicalDescription()
Returns the canonical description of this coordinate system instance

Returns:
the canonical description of this coordinate system instance


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.