## Calculating the angle of rotation

Discuss any questions about BEPUphysics or problems encountered.
ApppStudio
Posts: 9
Joined: Thu Jul 27, 2017 12:28 pm

### Calculating the angle of rotation

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

Norbo
Site Admin
Posts: 4680
Joined: Tue Jul 04, 2006 4:45 am

### Re: Calculating the angle of rotation

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?

ApppStudio
Posts: 9
Joined: Thu Jul 27, 2017 12:28 pm

### Re: Calculating the angle of rotation

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

### Who is online

Users browsing this forum: No registered users and 4 guests