[ x'] [ m00 m01 m02 ] [ x ] [ m00 * x + m01 * y + m02 ] [ y'] = [ m10 m11 m12 ] [ y ] = [ m10 * x + m11 * y + m12 ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]Though AffineTransform is often associated with drawing, it is not tied in any way to the Graphics class. It is purely mathematical.
| Tips | Rotating Images |
| Manual Use | Learning More |
| Drawing | Links |
| Mouse Co-ordinates |
The basic idea is this. A transform maps every point x,y onto a new point, by a combination of rotation, scaling, translation and mirroring. You can manually transform a point like this:
You can also simply plug an AffineTransform into your Graphics2D object. Then you can specify simple coordinates and the drawing will appear in transformed coordinates. Note that with Graphics2D, your coordinates are doubles not ints.
The catch is, the mouse knows nothing about your transforms. You need to convert mouse screen coordinates to your user-coordinates. This is the inverse of what you normally do, namely converting convenient user coordinates to pixel display coordinates. For this, you need the inverse of your transform.
You can learn more with a Google search.
|
|
You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) |
| http://mindprod.com/jgloss/affinetransform.html | J:\mindprod\jgloss\affinetransform.html | |
![]() | Please email your feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording,
broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.179.213] | |
| Feedback | You are visitor number 39,250. | |