Page 1 of 1

Calculating the angle of rotation

Posted: Wed Aug 02, 2017 1:37 pm
by ApppStudio
I know this is a simple calculation but having a brain freeze here I have an object which is moving around and at any given point I want to find the rotation angle of it I have tried getting the forward vector x and z and doing the following and its giving me strange results

var angler = MathHelper.ToRadians((float)(Math.Atan2(Board.WorldTransform.Forward.Z, Board.WorldTransform.Forward.X) * 180.0 / Math.PI))

What am I doing wrong

Re: Calculating the angle of rotation

Posted: Wed Aug 02, 2017 8:44 pm
by Norbo
The only oddity there is that the angle, returned in radians from Atan2, is being converted to degrees, and then back to radians. In order to know what's going wrong, you'll have to move up a level- what are you actually trying to do with this, and what do you expect it to do, and what are you getting instead?

Re: Calculating the angle of rotation

Posted: Thu Aug 03, 2017 2:46 pm
by ApppStudio
Thanks for you reply Norbo and appologies I have now sorted it I had my x and z the wrong way round for my world space brain melt down over lol