# Re: auto-scaling polygons using affinetransform but maintaining unscaled lenghts

Graham Street wrote:
```I've been tackling this problem for some time and am not having much
luck.
```
`This is not a question of luck.`

```I'm hoping someone has some experience with this and can shed
some light.
```

Well, since you play this "I want to do some zooming, scaling, transformation" game for over a month with us now, may I suggest that you spend some time to comprehend what you are doing. Instead of just throwing more and more and stranger and stranger code onto the problem. You will probably not hit a lucky number unless you know what you are doing.

```c. change the individial edges in my shape to reflect the transform by
iterating through a transformed version of the polygon, replacing the
edge coordinates with the coordinates from the transformed polygon.
```

This just does not make sense. Why, why, why, why, why? Why do you simultaneous scale the data's display and the data? What's the purpose of scaling twice, and particular of scaling your data, which is supposed to be in world coordinates? No, don't tell me. Answer it for yourself.

this works ok,
`Only that it doesn't make sense.`

```although the lengths dont end up being exactly 120% of
what they were--  a length of 100 might become 118.251535 or some
strange number like that.
```
`They are not strange.`

But my real challenge is maintaining the original lengths for display
as inches (in spite of the auto-scaling)

No, the real challenge is that you spend some time to understand what you are actually doing. You could for example try doing:

* Write down your requirements. Not for us, for you. You changed your story several times, I really don't care any more what you want to do, but do *you* know what you want? Not in some abstract "do what I mean" way, in a precise way.

* Do *you* know the math to do it? If not, learn it. Learn the math involved in linear transformations of cartesian coordinate system. This is what AffineTransform does, but you apparently don't understand it.

* Get some basic book about (2D) vector computer graphics, or google for some introduction. Pay special attention to the parts where people talk about coordinate systems, coordinate system transformations, how the stuff relates and where and when you typically work in which coordinate system.

* Learn the basics of the common floating point number representation and arithmetic in a computer, and why they are typically not exact.

* Work through Sun's 2D tutorial: http://java.sun.com/docs/books/tutorial/2d/index.html

* Work through Sun's 2D programmer's guide: http://java.sun.com/j2se/1.5.0/docs/guide/2d/spec/j2d-bookTOC.html

`All this would cost you less time than you have already spent.`

```/Thomas
--
The comp.lang.java.gui FAQ:
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
.```

## Relevant Pages

• Re: transformations
... Jonno wrote: ... > A lot of people seem to think about transformations as applying to ... > glTranslate, glRotate etc, is that you are transforming a *coordinate ... > So, you call glTranslate, and the coordinate system moves. ...
(comp.graphics.api.opengl)
• Re: Translation and Parallel Projection
... Transformations are confusing and people who have been working in 3D ... a mapping between one coordinate system and another coordinate system. ...
(microsoft.public.win32.programmer.directx.graphics)
• transformations
... is only one coordinate system involved. ... I could think of the columns of the rotation matrix ... but just a change of frame. ... Apply the sequence of transformations to the standard basis vectors ...
(comp.graphics.algorithms)
• Re: Parallelepiped coordinate system
... I would like to maintain a coordinate system that defines a ... coming out of it as unit vectors, and then carry out transformations ... is a matrix that transforms from the homogeneous Cartesian coordinates ... The matrix that does the reverse is the inverse ...
(comp.graphics.algorithms)