How to work out yaw,pitch and roll
Firstly please accept my apologies if this problem is very basic and not putting in a mathamatically correct way, i''m very new to 3D programming
I am trying to calculate the yaw, pitch and roll values that would be needed to rotate a model to point towards ( or pass through ) any given 3D point in world space (v3).
I have say, a solid bar with its origin at one end (v1), I know the length of the bar (v2), and it''s current yaw, pitch and roll rotation.
v2
| v3
| /
| /
| /
|/
v1
I am currently working out the x,y and z angles using
ax = atan(( v3.y - v1.y) / fabs ((v3.z - v1.z)))
ay = atan(( v3.z - v1.z) / fabs ((v3.x - v1.x)))
az = atan(( v3.x - v1.x) / fabs ((v3.z - v1.z)))
I was hoping that by using ax,ay,az as yaw, pitch and roll values, this would work, but it doesn''t.
It seems close, but not right, so i''m not sure whether or not i''m totally barking up the wrong tree. If anyone could help explain where i''m going wrong, or if i''m going about it in the totally wrong way, i''d be very grateful.
I don''t know if this is relevant, but i''m using DX8 and C++. Once again, sorry if this is a simple prob, and if the way it''s presented isn''t correct.
Thank you in advance.
Try using atan2 rather than atan. atan only returns angles in the range ( -pi/2, pi/2 )
[edited by - Paradigm Shifter on August 9, 2002 8:22:48 AM]
[edited by - Paradigm Shifter on August 9, 2002 8:22:48 AM]
"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley
Thank you PS for your reply, it''s definately helped, I think i''ve cracked the problem now, definately getting closer anyway. It''s times like these I wish i''d have listened better in the maths lessons at school, slowly getting to grips with it though.
Why don''t maths teachers point out to kids that the stuff they''re teaching is really cool and useful for things like this ?
Thanks again for the reply,
Jase
Why don''t maths teachers point out to kids that the stuff they''re teaching is really cool and useful for things like this ?
Thanks again for the reply,
Jase
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement