**THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED**

*On 30/03/2008 at 15:58, xxxxxxxx wrote:*

User Information:

Cinema 4D Version: R9-R10.5

Platform: Windows ; Mac ; Mac OSX ;

Language(s) : C++ ;

---------

I'm using this code to rotate a bone which points along the +Z axis to match another vector. Both are made relative to the origin. The results are not as expected. Any ideas (esp. with respect to the angle calculation) :

> `Vector v1 = Vector(0.0f,0.0f,1.0f); \> Vector v2 = !epBB; \> Vector axis = v1%v2; \> // Signed 3D angle between two vectors: atan2(dot(normal,cross(v1,v2)), dot(v1,v2)) \> Real angle = atan2((!axis)\*axis, v1\*v2); \> Matrix bm; \> if (Abs(angle) < 0.00001f) \> bm = MatrixMove(bc->GetVector(IPP_ORIGIN)) \* MatrixScale(Vector(epBBlen)); \> else \> bm = MatrixMove(bc->GetVector(IPP_ORIGIN)) \* RotAxisToMatrix(!axis, angle) \* MatrixScale(Vector(epBBlen));`

As far as I can tell, the atan2 calculation is returning incorrect angles (first off, all of the bones' angles are positive which doesn't seem possible). This is the *only* algorithm that I could find online to use atan2() for getting the angle between vectors - but I'm not trusting it at the moment.

Thanks