Subject:
|
Re: Another matrix inverse question
|
Newsgroups:
|
lugnet.cad
|
Date:
|
Tue, 10 Apr 2007 04:40:10 GMT
|
Viewed:
|
1727 times
|
| |
| |
In lugnet.cad, Brian Durney wrote:
> Hello,
> I read James Reynolds' question about inverse matrices and the responses with
> interest since I similar questions about matrix inverses. I used Travis's
> TCVector::invertMatrix code as the base for a Java function. Other than the
> change to Java and two-dimensional indices, it should be pretty much the same
> function. However, when I tried to use it in my program it didn't work right.
> When I multiplied the original matrix by the inverse, the bottom row of the
> product is not right. I double- (and triple-) checked the adaptation but found
> no problems. I made a simpler test case and the output from it is this:
>
> $ java Xform
> x1
> 1.5 0.0 0.0 0.0
> 0.8 1.0 0.0 0.0
> 0.0 0.0 3.0 0.0
> 5.0 4.0 0.0 1.0
> x1 inverse det: 0.22222222
> 0.6666667 -0.0 0.0 0.0
> -0.53333336 1.0 -0.0 0.0
> 0.0 -0.0 0.33333334 0.0
> -10.7 -4.0 -0.0 1.0
> x1.postMultiply(x2)
> 1.0 0.0 0.0 0.0
> 0.0 1.0 0.0 0.0
> 0.0 0.0 1.0 0.0
> -9.5 0.0 0.0 1.0
>
> NOTE: According to http://www.concentric.net/~Ttwang/tech/javafloat.htm
> "-0.0" is numerically identical to "0.0".
>
> It seems that the bottom row of the product is the problem, so I rechecked the
> statements that generate the left column of the inverse, but they look OK. (I
> think the left column of the inverse is the correct part to check for that
> problem...)
>
> If anyone (Travis?) is brave and/or energetic enough to look at the source code,
> it is at http://zephyr.uvsc.edu/~brian/Xform.java
>
> Please let me know if you have comments or suggestions.
I think you've converted Travis' code properly, but just looking at the code,
I'd say it's only intended to produce the inverse of the upper-left 3x3 matrix.
None of the other rows or the determinant depend in any way on the 4th row, and
it's calculation doesn't include the determinant at all. I'd say the 4th row may
be used by Travis for some other purpose, maybe some scaling factor or
something, but I'd have to wade through the rest of the LDview source to confirm
that.
So although you're using 4x4 matrices, you're only determining the inverse of
the upper-left 3x3 block. You can probably delete the chunks referring to the
4th row & column and use 3x3 matrices.
Regards
ROSCO
|
|
Message has 1 Reply: | | Re: Another matrix inverse question
|
| (...) Sorry about that. I wrote that code so long ago that I forgot that it wasn't a fully general-purpose matrix inversion routine. (Note that it is the way it is so that it will perform better, not because I was too lazy to do the whole shebang.) (...) (18 years ago, 10-Apr-07, to lugnet.cad)
|
Message is in Reply To:
| | Another matrix inverse question
|
| Hello, I read James Reynolds' question about inverse matrices and the responses with interest since I similar questions about matrix inverses. I used Travis's TCVector::invertMatrix code as the base for a Java function. Other than the change to Java (...) (18 years ago, 10-Apr-07, to lugnet.cad)
|
12 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|