Matrix Math Question

Miscellaneous Forums/General Discussion/Matrix Math Question

Ok, I had my quaternion math question before, and I think I have that under control now, but I'm trying to emulate a few more B3D functions.

At the moment I'm trying to emulate TFormVector. It's a very useful function, and I can handle the TForm, I think, but it's getting the correct matrix to transform it by that's giving me the issue.

I have the matrices for all entities.

As I see it, I essentially have three possible situations for this function to handle. :

1) From Entity1 ccordinate space to Entity2 coordinate space.
2) From Entity1 coordinate space to Global coordinate space.
3) From Global coordinate space to Entity1 coordinate space.

I'm just not sure what I need to do to get those matrices. It's not the math so much as the process. I know how to invert matrices, I know how to multiply matrices, etc. I just don't know what I need to do here. I have two books on game maths and they're both worthless if you don't know what to look up. If I knew what I needed to do, they'd tell me how, but I don't.

Can someone point me in the right direction for these three possibilities?

Something like this:

function tformvector( vec:Vector3,from:Entity,to:Entity)
  if from then vec = from.matrix.MultiplyVector3( vec )
  if to then vec = to.inversematrix.MultiplyVector3( vec )
  return vec
endfunction


Thanks, that makes sense now I see it.