Community
Participate
Working Groups
The subject is self-explanatory. It's already rotations and translations, for completeness it'd be really nice to have reflections too.
Is this what you are looking for? tr.scale(-1, 0) // reflection in the x axis
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.
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.
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.
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)
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 | |
s/x-axis/y-axis/g of course...
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.