# AffineTransform interpolation

Discussion in 'Java' started by bob smith, Oct 10, 2012.

1. ### bob smithGuest

Is it generally possible to interpolate between two AffineTransform objects?

For instance, you may want to get the object that is midway between two AffineTransforms.

bob smith, Oct 10, 2012

2. ### Roedy GreenGuest

On Wed, 10 Oct 2012 13:12:38 -0700 (PDT), bob smith
<> wrote, quoted or indirectly quoted someone
who said :

>
>For instance, you may want to get the object that is midway between two AffineTransforms.

I supposed you can create an Affine transform that uses the mean of
the parms of the two components. I think you would have to experiment.
--
Roedy Green Canadian Mind Products http://mindprod.com
The iPhone 5 is a low end Rolex.

Roedy Green, Oct 10, 2012

3. ### Knute JohnsonGuest

On 10/10/2012 1:12 PM, bob smith wrote:
> Is it generally possible to interpolate between two AffineTransform objects?
>
> For instance, you may want to get the object that is midway between two AffineTransforms.
>

It's been a long time since I've done any matrix math but I don't think
you can interpolate between transforms. Since a transform is a
multiplication does it even matter the order of transform if you do
multiples? You could rotate or translate half the distance.

I'm curious, what are you really trying to do?

--

Knute Johnson

Knute Johnson, Oct 10, 2012
4. ### Jeff HigginsGuest

On 10/10/2012 04:12 PM, bob smith wrote:
> Is it generally possible to interpolate between two AffineTransform objects?
>
> For instance, you may want to get the object that is midway between two AffineTransforms.
>

There was some discussion in "Linear Combination of Transformations",
Marc Alexa, 2002 available via Google Books. It was above my head
then and remains so now. David Eberly may have written some on the
subject. comp.graphics.algorithms has slowed to a crawl but some remain

Jeff Higgins, Oct 10, 2012
5. ### Eric SosmanGuest

On 10/10/2012 4:12 PM, bob smith wrote:
> Is it generally possible to interpolate between two AffineTransform objects?
>
> For instance, you may want to get the object that is midway between two AffineTransforms.

It's certainly possible to generate a transformation matrix
that is a weighted sum of two others:

[Mavg] = r * [Ma] + (1-r) * [Mb]

Alternatively, you could find a "geometric mean" as a matrix
whose square is the product of the two transformations:

[Mavg] * [Mavg] = [Ma] * [Mb]

(Note that the "matrix square root" is not unique. I don't know
how you'd decide which of many candidate root matrices to use, nor
how you might extend the idea to "weighted geometric means.")

Whether either of these satisfies your notion of "interpolate"
is something only you can determine.

--
Eric Sosman
d

Eric Sosman, Oct 10, 2012
6. ### LewGuest

Peter Duniho wrote:
> bob smith wrote:
>> Is it generally possible to interpolate between two AffineTransform objects?

>
>> For instance, you may want to get the object that is midway between two AffineTransforms.

>
> For interpolation of transforms, the usual technique is to use quaternions.
> They allow similar operations as matrix transforms, but are better-suited
> to interpolation.
>
> AFAIK, Java does not have built-in quaternion support, but it's just math.
> If you can't find a third-party library for that, you can read up on it and
> write your own without too much difficulty.

seems to have some promising links.

--
Lew

Lew, Oct 11, 2012
7. ### Knute JohnsonGuest

On 10/10/2012 1:12 PM, bob smith wrote:
> Is it generally possible to interpolate between two AffineTransform objects?
>
> For instance, you may want to get the object that is midway between two AffineTransforms.
>

Anybody remember the name of the programming language from the 70s that
had a bunch of built functions for things like matrix math? I think it
started with an A? School had a PDP 8 or 11 and it ran on that.

--

Knute Johnson

Knute Johnson, Oct 11, 2012
8. ### Gene WirchenkoGuest

On Wed, 10 Oct 2012 19:44:11 -0700, Knute Johnson
<> wrote:

>On 10/10/2012 1:12 PM, bob smith wrote:
>> Is it generally possible to interpolate between two AffineTransform objects?
>>
>> For instance, you may want to get the object that is midway between two AffineTransforms.
>>

>
>Anybody remember the name of the programming language from the 70s that
>had a bunch of built functions for things like matrix math? I think it
>started with an A? School had a PDP 8 or 11 and it ran on that.

BASIC?

HP 2000F BASIC had matrix functions. I only ever seriously used
it for array initialisation
MAT A=ZER
would zero array A. The matrix functions got dropped on any micro
BASICs I ever used.

Sincerely,

Gene Wirchenko

Gene Wirchenko, Oct 11, 2012
9. ### Arne VajhøjGuest

On 10/10/2012 10:44 PM, Knute Johnson wrote:
> Anybody remember the name of the programming language from the 70s that
> had a bunch of built functions for things like matrix math? I think it
> started with an A? School had a PDP 8 or 11 and it ran on that.

APL?

Arne

Arne Vajhøj, Oct 11, 2012
10. ### markspaceGuest

On 10/10/2012 7:44 PM, Knute Johnson wrote:
> On 10/10/2012 1:12 PM, bob smith wrote:
>> Is it generally possible to interpolate between two AffineTransform
>> objects?
>>
>> For instance, you may want to get the object that is midway between
>> two AffineTransforms.
>>

>
> Anybody remember the name of the programming language from the 70s that
> had a bunch of built functions for things like matrix math? I think it
> started with an A? School had a PDP 8 or 11 and it ran on that.
>

GraFORTH?

markspace, Oct 11, 2012
11. ### Knute JohnsonGuest

On 10/10/2012 7:55 PM, Arne Vajhøj wrote:
> On 10/10/2012 10:44 PM, Knute Johnson wrote:
>> Anybody remember the name of the programming language from the 70s that
>> had a bunch of built functions for things like matrix math? I think it
>> started with an A? School had a PDP 8 or 11 and it ran on that.

>
> APL?
>
> Arne
>
>

That's it Arne. It's been so long I just couldn't remember any more. I
wonder if it is still used?

--

Knute Johnson

Knute Johnson, Oct 11, 2012
12. ### Arne VajhøjGuest

On 10/11/2012 11:23 AM, Knute Johnson wrote:
> On 10/10/2012 7:55 PM, Arne Vajhøj wrote:
>> On 10/10/2012 10:44 PM, Knute Johnson wrote:
>>> Anybody remember the name of the programming language from the 70s that
>>> had a bunch of built functions for things like matrix math? I think it
>>> started with an A? School had a PDP 8 or 11 and it ran on that.

>>
>> APL?

>
> That's it Arne. It's been so long I just couldn't remember any more. I
> wonder if it is still used?

I think it is quite rare.

But it is still used.

I believe one of the more popular flavors/offspring is J:

http://www.jsoftware.com/

Arne

Arne Vajhøj, Oct 11, 2012
13. ### Gene WirchenkoGuest

On Fri, 12 Oct 2012 00:17:41 +0000 (UTC), Martin Gregorie
<> wrote:

>On Thu, 11 Oct 2012 18:02:18 -0400, Arne Vajhøj wrote:
>
>> On 10/11/2012 11:23 AM, Knute Johnson wrote:
>>> On 10/10/2012 7:55 PM, Arne Vajhøj wrote:

[snip]

>>>> APL?
>>>
>>> That's it Arne. It's been so long I just couldn't remember any more.
>>> I wonder if it is still used?

APL was my first thought for language, but I had never heard of
it on the hardware you mentioned.

>> I think it is quite rare.
>>
>> But it is still used.
>>

>It used to be described as the ultimate write-only language. I remember
>it being said that Ken Iverson wrote a GUI style text editor in 25 lines
>of APL, but was unable to understand it six months later.

Yow! That makes INTERCAL and Brainfuck mere pikers.

[snip]

Sincerely,

Gene Wirchenko

Gene Wirchenko, Oct 12, 2012
14. ### Arved SandstromGuest

On 10/11/2012 09:17 PM, Martin Gregorie wrote:
> On Thu, 11 Oct 2012 18:02:18 -0400, Arne VajhÃ¸j wrote:
>
>> On 10/11/2012 11:23 AM, Knute Johnson wrote:
>>> On 10/10/2012 7:55 PM, Arne VajhÃ¸j wrote:
>>>> On 10/10/2012 10:44 PM, Knute Johnson wrote:
>>>>> Anybody remember the name of the programming language from the 70s
>>>>> that had a bunch of built functions for things like matrix math? I
>>>>> think it started with an A? School had a PDP 8 or 11 and it ran on
>>>>> that.
>>>>
>>>> APL?
>>>
>>> That's it Arne. It's been so long I just couldn't remember any more.
>>> I wonder if it is still used?

>>
>> I think it is quite rare.
>>
>> But it is still used.
>>

> It used to be described as the ultimate write-only language. I remember
> it being said that Ken Iverson wrote a GUI style text editor in 25 lines
> of APL, but was unable to understand it six months later.
>
>> I believe one of the more popular flavors/offspring is J:
>>

> ... also by Iverson!
>
>

As far as J (or K for that matter) is concerned, it doesn't take but
some regular use of the language to master the symbols; the mnemonics
are pretty decent, and the extra operations created by combination with
.. and : relate quite well.

*Because* the language is so concise you typically have much less code
that you have to look at in order to figure out what's going on. Not
necessarily so with a pass of execution spread out over umpteen classes
and methods in Java or C#.

As wit any other language there is poor code written in J and good code
written in J. Good variable names, and choosing explicit or implicit
control structures as best suited, and in general not being too clever,