com.partnersoft.geometry.xy
Class XyAffineTransform

java.lang.Object
  extended by com.partnersoft.geometry.xy.AbstractXyTransform
      extended by com.partnersoft.geometry.xy.XyAffineTransform
All Implemented Interfaces:
Immutable, XyTransform

public class XyAffineTransform
extends AbstractXyTransform
implements Immutable

A vector matrix affine transform.

See the wikipedia page on Affine Transformation for a full discussion.

Putting matrices aside, here is the math:

 x1 = x0*scaleX + y0*shearX + translateX
 y1 = x0*shearY + y0*scaleY + translateY
 

Copyright 2007 Partner Software, Inc.

Version:
$Id$
Author:
Paul Reavis, Rich Stepanski, Richard Fay

Constructor Summary
XyAffineTransform(double scaleX, double shearX, double translateX, double shearY, double scaleY, double translateY)
          Tedious full constructor.
 
Method Summary
static XyAffineTransform forIdentity()
          Returns the identity transform.
static XyAffineTransform forRotation(XyRotation rotation)
          Returns a transformation matrix that will rotate by the given amount.
static XyAffineTransform forRotation(XyRotation rotation, XyPoint center)
          Returns a transformation matrix that will rotate by the given amount around the given center point.
static XyAffineTransform forScaling(double scale)
          Returns a transformation matrix that will scale by the given amount in both dimensions.
static XyAffineTransform forScaling(double scaleX, double scaleY)
          Returns a transformation matrix that will scale by the given amount for each dimension.
static XyAffineTransform forTranslation(double deltaX, double deltaY)
          Returns a transformation matrix that will translate by the given amount.
 double getScaleX()
          The x coordinate scaling element (m00) of the transformation matrix.
 double getScaleY()
          The y coordinate scaling element (m11) of the transformation matrix.
 double getShearX()
          The x coordinate shearing element (m01) of the transformation matrix.
 double getShearY()
          The y coordinate shearing element (m10) of the transformation matrix.
 double getTranslateX()
          The x coordinate translation element (m02) of the transformation matrix.
 double getTranslateY()
          The y coordinate translation element (m12) of the transformation matrix.
 boolean isIdentity()
          True if this is an identity transform.
 XyAffineTransform multipliedBy(XyAffineTransform nother)
          Does a matrix multiplication and returns the result.
 XyAffineTransform rotatedBy(XyRotation rotation)
          Rotates the transformation matrix by the given amount and returns the result.
 XyAffineTransform rotatedBy(XyRotation rotation, XyPoint center)
          Rotates the transformation matrix by the given amount around the given center and returns the result.
 XyAffineTransform scaledBy(double scale)
          Scales the transformation matrix by the given amount and returns the result.
 XyAffineTransform scaledBy(double scaleX, double scaleY)
          Scales the transformation matrix by the given amount and returns the result.
protected  XyPoint transformImp(XyPoint point)
          Subclasses must implement this to do the actual work of transformation.
 XyAffineTransform translatedBy(double deltaX, double deltaY)
          Translates the transformation matrix by the given amount and returns the result.
 
Methods inherited from class com.partnersoft.geometry.xy.AbstractXyTransform
transform, transform, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XyAffineTransform

public XyAffineTransform(double scaleX,
                         double shearX,
                         double translateX,
                         double shearY,
                         double scaleY,
                         double translateY)
Tedious full constructor. Be careful of your parameter order; it is m00, m01, m02, m10, m11, m12.

Method Detail

forIdentity

public static XyAffineTransform forIdentity()
Returns the identity transform.


forRotation

public static XyAffineTransform forRotation(XyRotation rotation)
Returns a transformation matrix that will rotate by the given amount.


forRotation

public static XyAffineTransform forRotation(XyRotation rotation,
                                            XyPoint center)
Returns a transformation matrix that will rotate by the given amount around the given center point.


forTranslation

public static XyAffineTransform forTranslation(double deltaX,
                                               double deltaY)
Returns a transformation matrix that will translate by the given amount.


forScaling

public static XyAffineTransform forScaling(double scale)
Returns a transformation matrix that will scale by the given amount in both dimensions.


forScaling

public static XyAffineTransform forScaling(double scaleX,
                                           double scaleY)
Returns a transformation matrix that will scale by the given amount for each dimension.


rotatedBy

public XyAffineTransform rotatedBy(XyRotation rotation)
Rotates the transformation matrix by the given amount and returns the result.


rotatedBy

public XyAffineTransform rotatedBy(XyRotation rotation,
                                   XyPoint center)
Rotates the transformation matrix by the given amount around the given center and returns the result.


translatedBy

public XyAffineTransform translatedBy(double deltaX,
                                      double deltaY)
Translates the transformation matrix by the given amount and returns the result.


scaledBy

public XyAffineTransform scaledBy(double scaleX,
                                  double scaleY)
Scales the transformation matrix by the given amount and returns the result.


scaledBy

public XyAffineTransform scaledBy(double scale)
Scales the transformation matrix by the given amount and returns the result.


multipliedBy

public XyAffineTransform multipliedBy(XyAffineTransform nother)
Does a matrix multiplication and returns the result.


transformImp

protected XyPoint transformImp(XyPoint point)
Description copied from class: AbstractXyTransform
Subclasses must implement this to do the actual work of transformation. It behaves the same way as AbstractXyTransform.transform(XyPoint), except that you do NOT have to check for identity - that will be done automatically.

Specified by:
transformImp in class AbstractXyTransform

isIdentity

public boolean isIdentity()
True if this is an identity transform. The identity returns its input unchanged.

Specified by:
isIdentity in interface XyTransform

getScaleX

public double getScaleX()
The x coordinate scaling element (m00) of the transformation matrix.


getScaleY

public double getScaleY()
The y coordinate scaling element (m11) of the transformation matrix.


getShearX

public double getShearX()
The x coordinate shearing element (m01) of the transformation matrix.


getShearY

public double getShearY()
The y coordinate shearing element (m10) of the transformation matrix.


getTranslateX

public double getTranslateX()
The x coordinate translation element (m02) of the transformation matrix.


getTranslateY

public double getTranslateY()
The y coordinate translation element (m12) of the transformation matrix.