Bug 103975 - Transform needs better documentation
Summary: Transform needs better documentation
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords: Documentation
Depends on:
Blocks:
 
Reported: 2005-07-15 05:02 EDT by David Walser CLA
Modified: 2020-02-08 02:07 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Walser CLA 2005-07-15 05:02:28 EDT
The subject is self-explanatory.  It's already rotations and translations, for 
completeness it'd be really nice to have reflections too.
Comment 1 Silenio Quarti CLA 2005-07-21 18:28:30 EDT
Is this what you are looking for?

tr.scale(-1, 0) // reflection in the x axis
Comment 2 David Walser CLA 2005-07-22 03:24:41 EDT
Oh my, well of course that makes sense now :o(

I suppose that means the functionality is there and this could be closed.  Just
the fact that it wasn't immediately obvious to me leaves me with a little
concern.  Here's some ideas that may help, but it's up to you:
o Having a reflect method for convenience anyway might be nice
o Maybe in the Javadoc documentation at the top of the class have some examples,
like the one you gave me in another bug about how the translate translates the
origin around which rotations will be done, as well as the one you just gave me
about negative scales being a reflection.

I guess that's all I can think of.  It's so obvious now that you told me how to
do it, but for some reason it didn't hit me before.  Good that the functionality
is there though; thanks for the explanation and do with this bug what you will.
Comment 3 Silenio Quarti CLA 2005-07-25 16:29:20 EDT
reflect() is not provide in any of the underline OSs we use. I have not seen a
graphics library that has this method. So I don't think we will provide.

But I agree that the documentation and samples of Transform needs to be
improved. I changed the summary to reflect that.
Comment 4 David Walser CLA 2005-07-25 19:38:33 EDT
I actually found a Java Transform class with reflect() methods when Googling, 
but you can handle this however you feel appropriate. 
 
While we're on the reflect subject, given a drawing with a height and width of 
SIZE, a horizontal in-place reflection would be: 
tr.translate(SIZE,0); 
tr.scale(-1,1); 
 
and a vertical in-place reflection would be: 
tr.translate(0,SIZE); 
tr.scale(1,-1); 
 
So you should have had a 1 not a zero in your scale example, but the scale 
examples make sense to me.  What doesn't make sense is the translate lines in 
my example.  I don't understand why SIZE wouldn't be negative.  Perhaps you 
could explain this one. 
Comment 5 Randy Hudson CLA 2005-07-26 10:01:40 EDT
If you are trying to reflect about a specific y = b axis, you need to translate 
to that location, reflect about y-axis, then translate "back" to y=0.  Your 
code example is missing the third part:
tr.translate(0,-SIZE)
Comment 6 David Walser CLA 2005-07-26 11:43:07 EDT
Actually what I was trying to do in my example was reflect it and then 
translate it back into the same position it started in, so I wasn't missing 
anything, but if I wanted to reflect over some axis, yes, I'd have to do what 
you said. 
 
What I was wanting to have cleared up was why the translation had to be in the 
direction it was.  The way I'm picturing it in my head would be that a 
scale(-1,1) would basically multiply the x-coordinates by -1 so that: 
 
x-axis 
v 
| 
|image 
| 
 
translate(-SIZE,0) 
 
x-axis 
     v 
     | 
image| 
     | 
 
scale(-1,1) 
 
x-axis 
v 
| 
|egami 
| 
 
but that's actually not how it works.  To get the final picture I just gave, 
you have to translate(SIZE,0) then scale(-1,1).  I don't understand why that 
doesn't leave you with: 
 
     x-axis 
          v 
          | 
egami     | 
          | 
Comment 7 David Walser CLA 2005-07-26 12:02:52 EDT
s/x-axis/y-axis/g  of course... 
Comment 8 Nikita Nemkin CLA 2020-02-08 02:07:57 EST
Transform is a very common affine 3x2 transformation matrix. Every 2D graphics toolkit has an equivalent.

Docs could be improved across the board, no reason to single out Transform.