BafflinTransform

B

bob smith

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?
 
M

markspace

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.
 
L

Lew

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

http://sscce.org/

"Hey, doctor, I keep trying to get healthy. I've tried medicine and I've tried
exercise, and neither one produces my desired result."

Ask smarter questions.
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.

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.
 
G

Gene Wirchenko

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


http://sscce.org/

"Hey, doctor, I keep trying to get healthy. I've tried medicine and I've tried
exercise, and neither one produces my desired result."


Ask smarter questions.

Besides SSCCE, there is
http://www.catb.org/~esr/faqs/smart-questions.html
How To Ask Questions The Smart Way
by Eric Steven Raymond
It discusses at length how to properly ask technical questions.

The main benefit of following it is that people will have more,
relevant details and stand a better chance of knowing what you are
discussing and what might be done about.

A quieter, but more powerful benefit, is that to ask a technical
question properly, you have to think about your problem in a
structured manner, and often, this can lead to you being able to solve
the problem yourself.

[snip]

Sincerely,

Gene Wirchenko
 
J

Jeff Higgins

Am I the only one who gets incredibly confused by AffineTransform?

According to the docs:
concatenate [this] = [this] x [Tx]
preconcatenate [this] = [Tx] x [this]
 
L

Lew

Jeff said:
bob said:
Am I the only one who gets incredibly confused by AffineTransform?

According to the docs:
concatenate [this] = [this] x [Tx]

preconcatenate [this] = [Tx] x [this]
I never know when to preConcatenate or concatenate. Then I try both possibilities,
and a lot of times neither one produces my desired result.

If neither produces the desired result, then it isn't the choice of method that is the problem.
 
A

Arne Vajhøj

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


http://sscce.org/

"Hey, doctor, I keep trying to get healthy. I've tried medicine and I've tried
exercise, and neither one produces my desired result."


Ask smarter questions.


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.

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.

Arne
 
G

Gene Wirchenko

[snip]
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.

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.

It is still SSCCE, just not in code.

Sincerely,

Gene Wirchenko
 
J

Jeff Higgins

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.

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).

To me it seems rather the bob is conducting a poll or troll.
 
B

bob smith

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.
 
G

Gene Wirchenko

[snip]

To me it seems rather the bob is conducting a poll or troll.

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

[snip]

Sincerely,

Gene Wirchenko
 
G

Gene Wirchenko

On Thu, 4 Oct 2012 07:22:30 -0700 (PDT), bob smith

[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
 
J

John B. Matthews

Gene Wirchenko said:
On Thu, 4 Oct 2012 07:22:30 -0700 (PDT), bob smith

[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>
 
M

markspace

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.
 
L

Lew

Arne said:
.. . .

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:
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.
 
G

Gene Wirchenko

Gene Wirchenko said:
On Thu, 4 Oct 2012 07:22:30 -0700 (PDT), bob smith

[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
 
J

John B. Matthews

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);
}
 
M

markspace

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top