Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Orientating objects to align with a specific axis

  1. Jul 31, 2010 #1

    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 alot for any help offered :wink:
  2. jcsd
  3. Jul 31, 2010 #2
    Hi this resource:

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

    Question 39 I believe firmly answers the question ;o)
    Last edited by a moderator: May 4, 2017
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook