Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > BafflinTransform

Reply
Thread Tools

BafflinTransform

 
 
bob smith
Guest
Posts: n/a
 
      10-04-2012
On Wednesday, October 3, 2012 10:46:00 AM UTC-5, markspace wrote:
> On 10/3/2012 7:58 AM, bob smith wrote:
>
> > Am I the only one who gets incredibly confused by AffineTransform?

>
> >

>
> > I never know when to preConcatenate or concatenate. Then I try both

>
> > possibilities, and a lot of times neither one produces my desired

>
> > result.

>
> >

>
> > Any tips?

>
>
>
>
>
> I suspect some math is involved.
>
>
>
>
>
> Seriously, it's matrix algebra, and the formulas are given in each
>
> method description. You need to work out what it is you are actually
>
> doing first. Which you haven't told us, so I'm assuming that's the problem.


It seems like when I want to "tack on" an operation, it is actually a preConcatenate.

This is counterintuitive to me.

Also, when you are just doing commutative operations, like just translation, it doesn't matter whether you preConcatenate or concatenate.

What happened was I started with just translations and was concatenating.

Then, I added rotation, and it did not work right whether I preConcatenated or concatenated. The issue was that I should have been preConcatenating the translations that I had already programmed in.
 
Reply With Quote
 
 
 
 
Gene Wirchenko
Guest
Posts: n/a
 
      10-04-2012
On Thu, 04 Oct 2012 03:26:41 -0400, Jeff Higgins
<> wrote:

>On 10/03/2012 09:36 PM, Arne Vajhøj wrote:
>>>> bob smith wrote:


[snip]

>To me it seems rather the bob is conducting a poll or troll.
> >>>> Am I the only one who gets incredibly confused by AffineTransform?


Oh, come off it. Taking the literal meaning when it is rather
obviously not intended is silly.

[snip]

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
 
 
 
Gene Wirchenko
Guest
Posts: n/a
 
      10-04-2012
On Thu, 4 Oct 2012 07:22:30 -0700 (PDT), bob smith
<> wrote:

[snip]

>It seems like when I want to "tack on" an operation, it is actually a preConcatenate.
>
>This is counterintuitive to me.
>
>Also, when you are just doing commutative operations, like just translation, it doesn't matter whether you preConcatenate or concatenate.


Matrix multiplication is NOT commutative.

[snip]

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      10-04-2012
In article <>,
Gene Wirchenko <> wrote:

> On Thu, 4 Oct 2012 07:22:30 -0700 (PDT), bob smith
> <> wrote:
>
> [snip]
>
> > It seems like when I want to "tack on" an operation, it is
> > actually a preConcatenate.
> >
> > This is counterintuitive to me.
> >
> > Also, when you are just doing commutative operations,
> > like just translation, it doesn't matter whether you
> > preConcatenate or concatenate.

>
> Matrix multiplication is NOT commutative.
>
> [snip]


Absolutely correct, as well as pithy. Conceptually, it may help
to think of a series of (post-) concatenated transformations as
having been applied in a last-specified-first-applied order. In
the example cited below, a small, U-shaped Polygon is centered
about the origin. The following transform rotates, scales and
translates the Polygon in the (apparent) reverse of program
order:

AffineTransform at = new AffineTransform();
at.translate(SIZE/2, SIZE/2);
at.scale(60, 60);
at.rotate(Math.PI/4);

<https://sites.google.com/site/drjohnbmatthews/point-in-polygon>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      10-04-2012
On 10/4/2012 10:58 AM, John B. Matthews wrote:

> In article <>,
>>
>> Matrix multiplication is NOT commutative.
>>
>>


> Absolutely correct, as well as pithy. Conceptually, it may help
> to think of a series of (post-) concatenated transformations as
> having been applied in a last-specified-first-applied order.



Another rule of thumb is that scaling and rotating tend to occur around
the origin, not the translation point. So if you scale or rotate an
already-translated AffinceTransform, you might get unintended results.

The method I'm used to from 3D graphics is to translate any objects back
to the origin, scale and rotate, then translate them back to their
original/intended point in space. It's a literal three step process;
you can't put all that together in one matrix.

Given that AffineTransforms are 2D transforms, some results might be
different than the 3D equivalents. Like I said, some math might be
involved here.


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      10-04-2012
Arne Vajhøj wrote:
> Lew wrote:
>>> bob smith wrote:
>>>> Am I the only one who gets incredibly confused by AffineTransform?

>
>> No, but that isn't necessarily a reflection on the class.

>
>>>> I never know when to preConcatenate or concatenate. Then I try both
>>>> possibilities, and a lot of times neither one produces my desired
>>>> result.

>
>> http://sscce.org/

>

.. . .
>> So show us what you're trying to accomplish, what you've written as an SSCCE, and
>> what precisely, with copied and pasted output, what differs from your precise
>> expectations.

>
> Hm.
>
> If the original poster has a limited number of specific
> problems, then producing a SSCCE is a very good thing.
> But I don't see any indications of that.


Then you missed what you quoted:

>>>> Then I try both possibilities, and a lot of times neither one producesmy desired
>>>> result.


> To me it seems as if the original poster in general find
> it difficult to understand how to get it right (besides trial
> and error).
>
> It is not a SSCCE'able problem, because it is not about
> specific code.
>
> Instead it is about concepts and principles.


He mentioned specific code, but he didn't show it.

I asked him to show what he tried, as he claimed he'd tried it.

That's pretty damned specific.

--
Lew
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      10-04-2012
On Thu, 04 Oct 2012 13:58:13 -0400, "John B. Matthews"
<> wrote:

>In article <>,
> Gene Wirchenko <> wrote:
>
>> On Thu, 4 Oct 2012 07:22:30 -0700 (PDT), bob smith
>> <> wrote:
>>
>> [snip]
>>
>> > It seems like when I want to "tack on" an operation, it is
>> > actually a preConcatenate.
>> >
>> > This is counterintuitive to me.
>> >
>> > Also, when you are just doing commutative operations,
>> > like just translation, it doesn't matter whether you
>> > preConcatenate or concatenate.

>>
>> Matrix multiplication is NOT commutative.
>>
>> [snip]

>
>Absolutely correct, as well as pithy. Conceptually, it may help


Yes to the first, because I did not say much. I did not intend
the pithy. I took one course that dealt with graphics
transformations. The material was not covered as well as it could
have been. Preferring not to misstate, I kept my statement short.

Maybe, OP is going through what I did. I think he might benefit
from some study of matrix algebra.

[snip]

Sincerely,

Gene Wirchenko
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      10-04-2012
On 10/4/2012 3:26 AM, Jeff Higgins wrote:
> To me it seems rather the bob is conducting a poll or troll.


Why?

Problems understanding that stuff is pretty common.

Arne



 
Reply With Quote
 
John B. Matthews
Guest
Posts: n/a
 
      10-05-2012
In article <k4kldp$g1q$>, markspace <-@.> wrote:

> On 10/4/2012 10:58 AM, John B. Matthews wrote:
>
> > In article <>,
> >>
> >> Matrix multiplication is NOT commutative.
> >>

> > Absolutely correct, as well as pithy. Conceptually, it may help
> > to think of a series of (post-) concatenated transformations as
> > having been applied in a last-specified-first-applied order.

>


> Another rule of thumb is that scaling and rotating tend to occur
> around the origin, not the translation point. So if you scale or
> rotate an already-translated AffinceTransform, you might get
> unintended results.


Agree.

> The method I'm used to from 3D graphics is to translate any objects
> back to the origin, scale and rotate, then translate them back to
> their original/intended point in space. It's a literal three step
> process; you can't put all that together in one matrix.


Why not? Isn't that what a method like the anchored rotate() below does?
When it returns, the enclosing transform contains a single matrix that
does all three things when applied to a graphics context or used to
create a transformed Shape.

public void rotate(double theta, double anchorx, double anchory) {
translate(anchorx, anchory);
rotate(theta);
translate(-anchorx, -anchory);
}

> Given that AffineTransforms are 2D transforms, some results might be
> different than the 3D equivalents. Like I said, some math might be
> involved here.


--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      10-05-2012
On 10/4/2012 6:23 PM, John B. Matthews wrote:

> In article <k4kldp$g1q$>, markspace <-@.> wrote:
>> you can't put all that together in one matrix.



> Why not? Isn't that what a method like the anchored rotate() below does?



What I was trying to say, and did say in fact, was that you cannot
multiply out the three steps into a single matrix. Which is exactly
what I quoted above. You apparently read "matrix" as "method" and
thought I was talking about something else.

Yes, you can easily make a single method. You still need a minimum of
three matrix operations to accomplish the goal, however.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments