Subject:
|
Re: Another matrix inverse question (and answer?)
|
Newsgroups:
|
lugnet.cad
|
Date:
|
Wed, 11 Apr 2007 13:22:26 GMT
|
Viewed:
|
2477 times
|
| |
| |
In lugnet.cad, Timothy Gould wrote:
> In lugnet.cad, Brian Durney wrote:
> > In lugnet.cad, Brian Durney wrote:
> > > In lugnet.cad, Timothy Gould wrote:
> > > > In lugnet.cad, Brian Durney wrote:
> > > > > Thanks for the information, everyone. Although the test case I posted was
> > > > > arbitrary, I did some other tests with matrices that were used for rotations and
> > > > > translations. The upper-left 3x3 seemed to be OK, but the bottom row had
> > > > > problems. I'm guessing that the inversion routine wasn't written to include
> > > > > those.
> > > > >
> > > > > I wanted the inverse so that I could move a part back to the origin and do
> > > > > rotations in the local coordinate space. I think that what I will do is keep an
> > > > > inverse matrix with the transformation matrix, and every time I do a
> > > > > transformation (like rotate 45 degrees around the X axis) I will do the inverse
> > > > > (-45 degrees) and apply it to the inverse matrix.
> > > > >
> > > > > I suppose another possibility is to transform the origin and/or axis of rotation
> > > > > and then use quaternions to specify rotation around a point other than the
> > > > > origin, but it seems like that would have more opportunities for mistakes,
> > > > > considering my limited experience with quaternions.
> > > > >
> > > > > Thanks again for the help.
> > > > > Brian Durney
> > > >
> > > > Quarternions are, IMO, a bad way to do what matrices do well.
> > > >
> > > > For a rotation you don't need to (and shouldn't) calculate the inverse by a
> > > > routine. Just transpose (swap the off-diagonals) and you have the inverse.
> > > > There's no point running unneccessay numerical risks.
> > > >
> > > > Tim
> > >
> > > I can see the advantages of swapping the off-diagonals for inverting the
> > > rotation(s), but that still leaves the question of how to invert translations.
> > > In a current example I'm looking at, a minifig hand, the hand is rotated 45
> > > degrees, translated, rotated about 9 degrees (with the arm) and translated
> > > again. After those operations the transform matrix looks like this:
> > >
> > > handL xform
> > > 0.98543465 -0.17005472 0.0 0.0
> > > 0.12024684 0.6968075 0.70710677 0.0
> > > -0.12024684 -0.6968075 0.70710677 0.0
> > > 23.558212 25.872986 -10.0 1.0
> > >
> > > An inverse transform matrix that works looks like this:
> > > handLInverse
> > > 0.98543465 0.12024684 -0.12024684 0.0
> > > -0.17005472 0.6968075 -0.6968075 0.0
> > > 0.0 0.70710677 0.70710677 0.0
> > > -18.815256 -13.790222 27.932358 1.0
> > >
> > > The off-diagonals for the rotation are swapped as you said (although that's not
> > > how this inverse was made), but the inverse translation has no obvious
> > > correspondence to the original composite transformation. Is there any way to
> > > calculate the inverse translation as well as the inverse rotation?
> > > Thanks,
> > > Brian Durney
> >
> > I think I just answered my own question. I applied the inverse rotation
> > (calculated by swapping the off-diagonals) to the translation row of the
> > original transformation and then negated it to get the translation row in the
> > inverse. That worked correctly for my example, but does it make sense as a
> > general technique?
> > Thanks again,
> > Brian Durney
>
> If it's only rotations then it should make sense. Another way of passing the
> information is as follows
>
> (M,x) where M is the matrix and x is the translation vector
>
> the inverse of this is (Mi,-Mi x) which you can see by showing that an operation
> transforms y to yp by
>
> yp=M y + x
>
> so to reverse this we need
>
> Mi (M y + x) + -Mi x = y
>
> Hope that all makes sense.
>
> Tim
Yes, that makes sense. Looking back at Travis's code, I see that's basically
what's happening there, except that some references to the original matrix
should be references to the inverse matrix. He probably used it only to invert
rotations (with no translations) and so didn't catch the bug.
I will update my Xform Java class (http://zephyr.uvsc.edu/~brian/Xform.java) in
case anyone wants to take a look at the new version.
Thanks again for everyone's help, including the original matrix inversion
thread.
Brian Durney
|
|
Message is in Reply To:
| | Re: Another matrix inverse question (and answer?)
|
| (...) If it's only rotations then it should make sense. Another way of passing the information is as follows (M,x) where M is the matrix and x is the translation vector the inverse of this is (Mi,-Mi x) which you can see by showing that an operation (...) (18 years ago, 11-Apr-07, to lugnet.cad)
|
12 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|