Matrix maths and re-parenting objects
This is a common problem and one that’s very easy to solve if you think about it the right way. Lets say you have two objects A and B and you want to re-parent B to A what you need is the relative transform. If you think about this in terms of vectors first the solution is much clearer, to create the relative transform you need to calculate Rv = Bv – Av. The equivalent matrix operation to ( - A ) is to multiply by the inverse of A i.e. Rm = Bm * Inv(Am). Once you have Rm you can calculate the position of B from A i.e. solve Rm = Bm * Inv(Am) for Bm giving
Rm * Am = Bm * Inv(Am) * Am
Rm * Am = Bm
Bm = Rm * Am
Note, this works in both world space and local space as long as A and B are both in world or local space. If Am and Bm are in the same local space then once you have Bm you can use the world space transform of A to find the world space transform of B. If Am and Bm are both in world space then transform them to local space by multiplying by the inverse of there world space transforms first.
Rm * Am = Bm * Inv(Am) * Am
Rm * Am = Bm
Bm = Rm * Am
Note, this works in both world space and local space as long as A and B are both in world or local space. If Am and Bm are in the same local space then once you have Bm you can use the world space transform of A to find the world space transform of B. If Am and Bm are both in world space then transform them to local space by multiplying by the inverse of there world space transforms first.
Links
Collision Detection
http://www.harveycartel.org/metanet/tutorials/tutorialA.html
IIntersection Tests
http://mathworld.wolfram.com/Line-LineIntersection.html
Geometry
http://local.wasp.uwa.edu.au/~pbourke/geometry/
Misc
http://www.gamedev.net/reference/
Vector Maths For Animation
http://faculty.cs.tamu.edu/schaefer/teaching/441_Fall2008/lectures/3DTransformations.ppt
Everything you wanted to know about matrices, vectors, quaternions but were afraid to ask
http://web.archive.org/web/20041029003853/http:/www.j3d.org/matrix_faq/matrfaq_latest.html
Gauss-Seidel
http://www.ee.oulu.fi/~mpa/matreng/eem5_4-1.htm