# Extracting angles from a view matrix

This topic is 4595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

As the title suggests, I’m having troubles extracting my current camera angles from my view matrix. The code I'm using now looks like this: D3DVECTOR Angles; Float hyp = sqrtf(View._13 * View._13 + View._23 * View._23 + View._33 * View._33 ); Angles.x = atan2f( View._13, View._33 ) * 180 / PI; Angles.y = atan2f( View._23, hyp) * 180 / PI; Angles.z = 0.0f; I’ve tried many different things and read up on countless tutorials and this the closest I’ve got. Angles.x seems to be working fine, but Angles.y is way off. Any help on the matter of even a source to read up on would be greatly appreciated. Thanks! -Trav

##### Share on other sites
Maybe you could clarify what exactly you mean by camera angles? Angles relative to what exactly? Are you trying to find the points of your frustum? Please clarify exactly what you're trying to do

##### Share on other sites
I'm making a mod for my Half-Life2 server and one of the power-ups I’m trying to implement is an aim helper. In order to do so I need yaw, pitch, and roll angles (relative to 0,0,0…where 90 pitch is straight up, and 180 yaw is looking opposite to 0) in degrees to plug into Half-Life2’s SDK function that sets your aiming direction. I’m using D3DXMatrixLookAtLH to build a view matrix looking at the target from my current location, now I just need at way to extract the view angles. I’ve already been able to test and set the yaw angle just fine using the code above, now I just need to find the pitch value in my matrix. Then I’ll be able to find the angles’ offset between the current camera position and the target, divide it by a modifier, and add that to the camera position to create a slow aiming effect.

1. 1
Rutin
40
2. 2
3. 3
4. 4
5. 5

• 12
• 18
• 12
• 14
• 9
• ### Forum Statistics

• Total Topics
633359
• Total Posts
3011513
• ### Who's Online (See full list)

There are no registered users currently online

×