![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
Posts: n/a
|
These functions are used to numerically calculate solutions to linear systems and find eigenvalues of symmetric matrices. For details, see Mathematics for 3D Game Programming & Computer Graphics, Chapter 14.
SolveLinearSystem Code:
LUDecompose Code:
LUBacksubstitute Code:
LURefineSolution Code:
SolveTridiagonalSystem Code:
CalculateEigensystem Code:
Visit http://www.terathon.com for information about the book and C4 Engine. |
|
|
|
#2 |
|
Member
Join Date: Oct 2005
Location: Florida
Posts: 78
|
I have this book, and Eric has a great approach to several topics that are straight-forward in design.
I'd say this and Eberly's Appendix A in Game Physics are really all you need except for maybe more on fluid dynamics. I recall that Eric touches on it some including wave dynamics. I don't know about those goto's though ![]() corey |
|
|
|
|
|
#3 |
|
New Member
Join Date: Oct 2005
Posts: 27
|
That's a great book, any programmer that's interested in "3d" math should consider looking that book up
. That was a some good pieces of code. Thanks for posting this Eric, I learned a thing or two. |
|
|
|
|
|
#4 |
|
Member
Join Date: Oct 2004
Location: Roseville, CA
Posts: 41
|
Hi --
I just wanted to point out that the above post was actually made by a DevMaster staff member who asked my permission to post some code that's also available on my website (note different username). About the goto statements... I know a lot of coding philosophies consider them to be instruments of the devil that should never be used in a million years, but they do have their place. If the C language had a way to break out of nested loops, then I don't think the goto statement would be necessary, but right now, it's the most efficient way to do either of the following. Code:
Code:
In the code snippets, I use goto for the second case here so that I can jump to the cleanup code before returning. Using some of the more recent features of C (which are unfortunately not yet available in C++), I could have allocated the array of floats that need to be deleted as an auto on the stack (using variable-sized arrays). In C++, I could wrap the allocation of the float array in some kind of local object that would delete the array when the object is destroyed. Either of these would let me return at the points where I used the goto statement, and the compiler would automatically clean up. Is it worth the mess and confusion? Probably not in this case -- I'd prefer to keep it simple. -- Eric Lengyel |
|
|
|
|
|
#5 | ||
|
Member
Join Date: Oct 2005
Location: Florida
Posts: 78
|
Quote:
Quote:
You have to either duplicate code, duplicate return values or use a more extensive library.The follow up was unexpected and appreciated! Maybe one of you writers will do a wave/fluid example also.
___________________________________________
G3D 6.07 3D Engine Last edited by corey : 10-14-2005 at 05:42 PM. |
||
|
|
|
|
|
#6 |
|
Member
Join Date: Oct 2005
Posts: 54
|
Aww you only implemented the easy algorithms for general matrices
. The eigenvalue problem for 3x3 matrices can be solved closed form and can handle complex eigenvalues and eigenvectors which your method does not. |
|
|
|
|
|
#7 |
|
DevMaster Staff
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
|
Sure, complex eigenvalues are important in mathematics, but seriously, how often does one need to deal with them in a 3D graphics context?
___________________________________________
Currently working at Sucker Punch reedbeta.com - OpenGL demos and other projects Luabridge - a lightweight, dependency-free C++/Lua binding library. CD Lite - an unobtrusive, minimal CD player application for Windows. |
|
|
|
|
|
#8 |
|
Member
Join Date: Oct 2005
Posts: 54
|
The eigenvalues and eigenvectors of a rotation matrix are complex.
|
|
|
|
|
|
#9 |
|
DevMaster Staff
Join Date: Oct 2004
Location: Seattle, WA
Posts: 3,707
|
So? What are eigenvalues and eigenvectors actually used for in 3D graphics? As far as I know, primarily in things like finding best-fit OBBs, in which case the eigenvalues are all real since the covariance matrix is symmetric. Another case might be in analyzing real dynamical systems, in which case again the only eigenvectors you really care about are the real ones.
___________________________________________
Currently working at Sucker Punch reedbeta.com - OpenGL demos and other projects Luabridge - a lightweight, dependency-free C++/Lua binding library. CD Lite - an unobtrusive, minimal CD player application for Windows. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|