Orientating objects to align with a specific axis

  • Context: Undergrad 
  • Thread starter Thread starter Adder_Noir
  • Start date Start date
  • Tags Tags
    Axis Specific
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
Adder_Noir
Messages
239
Reaction score
0
Hi!,

I'm well into the world of computer graphics. Love to say it was great but well, it isn't.

I would like to know how I can take any object and have it orientate so its centre aligns perfectly with any arbitrary axis.

Think of a cylinder at the origin pointing down the x-axis. Well I would like to know how I can rotate it so it points directly down an axis denoted by say (1,1,0) essentially in this theoretical case rotating it 45 degress. I haven't got a clue how to do this and I'm a bit thick too at times.

I know it has something to do with inverse matrices and such. I can get all the required inverse, determinant stuff from DirectX hard-coded functions so I don't even need to do much math I just need the solution method.

Any ideas? Naturally I can get a unit vector pointing down the required axis easily enough but how do I go about acquiring the necessary transform matrix to get something to go from its present position to be aligned with a new axis? Sure I know it's a concoction of X,Y, & Z rotations but hell which order to apply them in even if I did have the necessary rotations? I'm proper confused!

Thanks a lot for any help offered :wink:
 
Physics news on Phys.org
Hi this resource:

http://web.archive.org/web/20041029003853/http:/www.j3d.org/matrix_faq/matrfaq_latest.html"

Question 39 I believe firmly answers the question ;o)
 
Last edited by a moderator: