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

Arctangent2 without square rooting?

  1. Mar 25, 2013 #1
    basically i have a problem where i am rotating 1 vector to be parallel to another

    i get the axis of rotation by the cross product of the 2 vectors
    the angle by the arctangent of the magnitude of the axis and the dot product of the 2 vectors


    arctangent2(magnitude(axis) , dotproduct(vector1,vector2))

    is quite intensive I BELIEVE BECAUSE magnitude is a sqr root.

    i'm wondering if could just do some kind of axis squared and dot product square or something
    and still get the right angle.

    Hope this makes sense.
  2. jcsd
  3. Mar 25, 2013 #2

    Ben Niehoff

    User Avatar
    Science Advisor
    Gold Member

    It would work, but atan2() is itself a pretty intensive function. I don't think the square root is the bottleneck here.

    There might be an even cleverer option. Remember that rotation matrices are built out of sin() and cos(), so you don't actually need the angle itself! You just need sin() and cos() of the angle. So you can make the entire problem algebraic, if you do some preliminary work by hand to figure out how to do it.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook