Arctangent2 without square rooting?

  • Context: Undergrad 
  • Thread starter Thread starter sparkzbarca
  • Start date Start date
  • Tags Tags
    Square
Click For Summary
SUMMARY

The discussion focuses on optimizing the calculation of the angle between two vectors for rotation without using square roots. The user employs the cross product to determine the axis of rotation and the dot product to find the angle using the arctangent function. It is concluded that while arctangent2 is computationally intensive, the square root calculation is not the primary bottleneck. An alternative approach is suggested, utilizing rotation matrices and the sine and cosine of the angle, which can simplify the problem algebraically.

PREREQUISITES
  • Understanding of vector mathematics, specifically cross product and dot product
  • Familiarity with trigonometric functions, particularly sine and cosine
  • Knowledge of rotation matrices in 3D space
  • Experience with computational efficiency in mathematical functions
NEXT STEPS
  • Explore the implementation of rotation matrices in 3D graphics
  • Research the mathematical properties of sine and cosine functions in angle calculations
  • Investigate optimization techniques for reducing computational intensity in vector operations
  • Learn about alternative methods for angle calculation that avoid square roots
USEFUL FOR

Mathematicians, computer graphics developers, and anyone involved in optimizing vector rotation calculations in programming or simulations.

sparkzbarca
Messages
7
Reaction score
0
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.
 
Physics news on Phys.org
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.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
Replies
1
Views
1K
  • · Replies 11 ·
Replies
11
Views
4K
Replies
3
Views
2K
Replies
21
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 43 ·
2
Replies
43
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K