• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

masonium

Inverse Matrix

10 posts in this topic

Does anyone know how to get the inverse of a 4*4 matrix? If matrix M = | a b c d | | e f g h | | i j k l | | m n o p | what would M^-1 be?
0

Share this post


Link to post
Share on other sites
There is no formula because it is found procedurally. If you have a matrix with actual values then you can take the cross product of that matrix with the one you listed. That produces a set of 16 equations with 16 unknowns. The cross product gives the left hand side of the equation and the identity matrix gives the right hand side. You then have to solve that system of equations for the sixteen unknowns. I think the easiest way to do that is to put it in a 17 by 16 matrix and transform it to reduced row echelon form.

Using a simple example say x+y=1 and 2x-3y=-1.

  
x y rhs
1 1 1
2 -3 -1

Subtract 2 times first row from second row

x y rhs
1 1 1
0 -5 -3

Multiply second row by -1/5

x y rhs
1 1 1
0 1 3/5

Subtract 1 times second row from first row

x y rhs
1 0 2/5
0 1 3/5

Answer x=2/5 and y=3/5


The process is pretty straight forward so hopefully that is enough to get you going. If not then I would suggest a book on linear algebra or trying to find a tutorial on solving systems of linear equations online.
0

Share this post


Link to post
Share on other sites
The inverse would be:

M -1 = C T /|M |

Where C is the co-factor matrix of M. |M| is the determinant of M.

Edited by - python_regious on October 12, 2001 11:26:53 AM
0

Share this post


Link to post
Share on other sites
The Inverse of a n*n matrix can easily be computed by using the Gauss-algorithm. Transform your matrix to |A and I| I=Identity matrix:

|a11 a12 a13 ..a1j 1 0 0 0 0...n|
|a21 a22 a23 ..a2j 0 1 0 0 0...n|
|a31 a32 a33 ..a3j 0 0 1 0 0...n| and so on

Now apply the Gauss-algorithm on this n*n equation system. It will give you a matrix of the form:

|a11 a12 a13...a1j 1 0 0 0 0...n|
|0 a22 a23...a2j val 1 val val val...n|
|0 0 a33...a3j val val 1 ....

The matrix on the right (former identity) are now used as
right handside vectors (y) of the equationsystem Ax=y1..yn, where
Ax is the matrix on the left. You can now calculate recursivly the solution of this equation system, starting at aij up to a11 and the first column of the right matrix as y, then proceeding, using y2 for the same leftside and so on.

For ex. a 4*4 matrix would give you 4 4-dimensional solutions.
These 4 vectors put in a matrix are the transposed inverted matrix. To get the regular inverse just swap the lines with
the colums. The algorithm also calculates the determinant as a
positive side-effect. detA=product of aii. This algorithm seems complicated at first, but is very effective if bigger matrices are involved.
There exist many variation of the Gauss-algorithm. I won''t explain ít here, but you should find enough information on the net.
good luck cruz
0

Share this post


Link to post
Share on other sites
Or if you are using the D3DX stuff, you can simply just call a D3DXMatrixInverse!

--Jeff
0

Share this post


Link to post
Share on other sites
Hehe, that''s a bit easier isn''t it. I''m a bit lost on the last part about the transpose.

  
Starting Matrix
1 2
3 4

Augmented Matrix
1 2 1 0
3 4 0 1

Subtract 3 times first row from second
1 2 1 0
0 -2 -3 1

Multiply second row by -1/2
1 2 1 0
0 1 3/2 -1/2

Subtract 2 times second row from first
1 0 -2 -1
0 1 3/2 -1/2

Extract inverse
-2 -1
3/2 -1/2



I don''t see where the transpose comes into play.
0

Share this post


Link to post
Share on other sites
The problem with LilBudyWizer's algorithm is that it presumes that all pivot-elements aii (the diagonal-elements used to eliminate the lines below) are different from 0. Otherwise a divide by 0 would occur. The algorithm I described uses 1-dimensional pivot-selection. (Sorry I forgot to mention that) This variation of Gauss can deal with the occurance of 0 as a pivot element. (It just selects another one, different from 0). If the algorithm can't find an pivot element different from 0 throughout the whole column, it terminates, which mathematically means the determinant is 0. That means the matrix is singular and cannot be inverted.


LilBudyWizer reduces the matrix at first to an upper triangular matrix and then to its canonical form. You can also do so, but for large matrices, the version with gauss-pivot is far more effective (with large I mean 4 and greater). To reduce the upper triangular matrix to ist canonical form you need to do the Gauss reduction one more time. This take actually more time

greets cruz

Edited by - cruz on October 12, 2001 2:17:48 PM

Edited by - cruz on October 12, 2001 2:22:15 PM
0

Share this post


Link to post
Share on other sites
By all means, don''t use Cramer''s rule (which is the cofactor method). Its much more expensive than Gaussian elimination, even for very small matrices such as the 4x4.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
0

Share this post


Link to post
Share on other sites
Cruz,

The second post wasn''t proposing a means, but rather my best guess at understanding your post. Perhaps if you gave an example using a 2 by 2 matrix I would better understand what you mean.
0

Share this post


Link to post
Share on other sites
Try this for general matrix/quaternion questions and answers:

[link]
http://skal.planet-d.net/demo/matrixfaq.htm
[/link]

You can find a very optimal way of performing a 4x4 inverse here:

[link]
http://developer.intel.com/design/pentiumiii/sml/24504301.pdf
[/link]

According to Intel, performing a matrix inverse yields faster results for Cramer''s rule than Gaussian elimination with dimensions <= 6. All the information and source code is available at the above link.

Bear in mind also that if your 4x4 matrices are *only* a combination of any of the following: translation, rotation, or scale, you can perform an "affine matrix" inverse much quicker than the above methods. Information available here:

[link]
http://www.cs.unc.edu/~gotz/code/affinverse.html
[/link]

HTH
0

Share this post


Link to post
Share on other sites