drasys.or.geom.rect2
Class Transform

java.lang.Object
  |
  +--drasys.or.geom.rect2.Transform

public class Transform
extends java.lang.Object
implements TransformI

An implementation of 2-D homogeneous transformations.

References:

Computer Graphics : Principles and Practice (Systems Programming)
    James D. Foley (Editor), et al; Hardcover


Constructor Summary
Transform()
          The default transform matrix is the identity matrix.
Transform(double r11, double r12, double r21, double r22, double tx, double ty)
          Sets the transform matrix directly from the arguments:
[r11, r12, 0]
[r21, r22, 0]
[tx, ty, 1]
Transform(PointI inPoint1, PointI inPoint2, PointI outPoint1, PointI outPoint2)
          Creates a transform that maps the two input points to the two output points using translation and scaling.
Transform(PointI inPoint1, PointI inPoint2, PointI outPoint1, PointI outPoint2, boolean preserveAspectRatio)
          Creates a transform that maps the two input points to the two output points using only translation and scaling.
Transform(RangeI inRange, RangeI outRange)
          Creates a transform that maps the input range to the output range using translation and scaling.
Transform(RangeI inRange, RangeI outRange, boolean preserveAspectRatio)
          Creates a transform that maps the input range to the output range using translation and scaling.
 
Method Summary
 void combine(TransformI transform)
          Includes the argument transform into this transform.
 PointI forward(PointI point)
          Returns a point that is translated, scaled and rotated in the forward direction.
 RangeI forward(RangeI range)
          Returns a range that is translated, scaled and rotated int the forward direction.
 PointI forwardTransform(PointI point)
          Returns a transformed point.
 RangeI forwardTransform(RangeI range)
          Returns a transformed range.
 CoordinateSystemI inputCoordinateSystem()
          Always returns 'rect2.CoordinateSystem';
 PointI inverse(PointI point)
          Returns a point that is translated, scaled and rotated in the inverse direction.
 RangeI inverse(RangeI range)
          Returns a range that is translated, scaled and rotated int the inverse direction.
 PointI inverseTransform(PointI point)
          Returns an inverse transformed point.
 RangeI inverseTransform(RangeI range)
          Returns an inverse transformed range.
 CoordinateSystemI outputCoordinateSystem()
          Always returns 'rect2.CoordinateSystem';
 double r11()
           
 double r12()
           
 double r21()
           
 double r22()
           
 void rotate(double angleInRadians)
          Adds a rotation to the transformation.
 void scale(double scaleX, double scaleY)
          Adds a scaling to the transformation.
 void set(double r11, double r12, double r21, double r22, double tx, double ty)
          Sets the transformation matrix elements where the matrix is:
[r11, r12, 0]
[r21, r22, 0]
[tx, ty, 1]
 java.lang.String toString()
           
 void translate(double deltaX, double deltaY)
          Adds a translation to the transformation.
 double tx()
           
 double ty()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Transform

public Transform()
The default transform matrix is the identity matrix.

Transform

public Transform(double r11,
                 double r12,
                 double r21,
                 double r22,
                 double tx,
                 double ty)
Sets the transform matrix directly from the arguments:
[r11, r12, 0]
[r21, r22, 0]
[tx, ty, 1]

Transform

public Transform(RangeI inRange,
                 RangeI outRange)
Creates a transform that maps the input range to the output range using translation and scaling. The X and Y scaling will have the same absolute magnitudes and the input proportions will be preserved.

Transform

public Transform(RangeI inRange,
                 RangeI outRange,
                 boolean preserveAspectRatio)
Creates a transform that maps the input range to the output range using translation and scaling. If 'preserveProportions' is true then the X and Y scaling will have the same absolute magnitudes and the input proportions will be preserved.

Transform

public Transform(PointI inPoint1,
                 PointI inPoint2,
                 PointI outPoint1,
                 PointI outPoint2)
Creates a transform that maps the two input points to the two output points using translation and scaling. The X and Y scaling will have the same absolute magnitudes and the input proportions will be preserved.

Transform

public Transform(PointI inPoint1,
                 PointI inPoint2,
                 PointI outPoint1,
                 PointI outPoint2,
                 boolean preserveAspectRatio)
Creates a transform that maps the two input points to the two output points using only translation and scaling. If 'preserveProportions' is true then the X and Y scaling will have the same absolute magnitudes and the input proportions will be preserved.
Method Detail

tx

public double tx()
Specified by:
tx in interface TransformI

ty

public double ty()
Specified by:
ty in interface TransformI

r11

public double r11()
Specified by:
r11 in interface TransformI

r12

public double r12()
Specified by:
r12 in interface TransformI

r21

public double r21()
Specified by:
r21 in interface TransformI

r22

public double r22()
Specified by:
r22 in interface TransformI

set

public void set(double r11,
                double r12,
                double r21,
                double r22,
                double tx,
                double ty)
Sets the transformation matrix elements where the matrix is:
[r11, r12, 0]
[r21, r22, 0]
[tx, ty, 1]
Specified by:
set in interface TransformI

combine

public void combine(TransformI transform)
Includes the argument transform into this transform.
Specified by:
combine in interface TransformI

translate

public void translate(double deltaX,
                      double deltaY)
Adds a translation to the transformation. Where the translation is given by:
[ 1, 0, 0]
[ 0, 1, 0]
[deltaX, deltaY, 1]
Specified by:
translate in interface TransformI

scale

public void scale(double scaleX,
                  double scaleY)
Adds a scaling to the transformation. Where the scaling is given by:
[scaleX, 0, 0]
[ 0, scaleY, 0]
[ 0, 0, 1]
Specified by:
scale in interface TransformI

rotate

public void rotate(double angleInRadians)
Adds a rotation to the transformation. Where the rotation is given by:
[ cos, sin, 0]
[-sin, cos, 0]
[ 0, 0, 1]
Specified by:
rotate in interface TransformI

forward

public PointI forward(PointI point)
               throws GeomException
Returns a point that is translated, scaled and rotated in the forward direction.
Specified by:
forward in interface TransformI

inverse

public PointI inverse(PointI point)
               throws GeomException
Returns a point that is translated, scaled and rotated in the inverse direction.
Specified by:
inverse in interface TransformI

forward

public RangeI forward(RangeI range)
               throws GeomException
Returns a range that is translated, scaled and rotated int the forward direction.
Specified by:
forward in interface TransformI

inverse

public RangeI inverse(RangeI range)
               throws GeomException
Returns a range that is translated, scaled and rotated int the inverse direction.
Specified by:
inverse in interface TransformI

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

inputCoordinateSystem

public CoordinateSystemI inputCoordinateSystem()
Always returns 'rect2.CoordinateSystem';

outputCoordinateSystem

public CoordinateSystemI outputCoordinateSystem()
Always returns 'rect2.CoordinateSystem';

forwardTransform

public PointI forwardTransform(PointI point)
                        throws GeomException
Returns a transformed point. Converts from the input coordinate system to the output coordinate system.

inverseTransform

public PointI inverseTransform(PointI point)
                        throws GeomException
Returns an inverse transformed point. Converts from the output coordinate system to the input coordinate system.

forwardTransform

public RangeI forwardTransform(RangeI range)
                        throws GeomException
Returns a transformed range. Converts from the input coordinate system to the output coordinate system.

inverseTransform

public RangeI inverseTransform(RangeI range)
                        throws GeomException
Returns an inverse transformed range. Converts from the output coordinate system to the input coordinate system.


Copyright(C)1997-2000 by DRA Systems all rights reserved. OpsResearch.com