# Arctangent2 without square rooting?

1. Mar 25, 2013

### sparkzbarca

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

however

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. Mar 25, 2013

### Ben Niehoff

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.