Jump to content
  • Advertisement
Sign in to follow this  
the_cyberlord

(topic reuse) best way to get coordinates out of a 3D direction?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

what is the best way to store 3D directions? TOPIC REUSE: what is the best way to get coordinates out of a 3D direction? before I used only 2 directions for my rotations (x,y) but now I have 3 of them (x,y,z) so I don't really know how to fix this code, or even if it's the best way to do it. Just changed the code because of my code redesign>> angle has now x,y,z. So this code now only applies to angle.y
GLvoid camera::change_dir(point &position, GLfloat angle, GLfloat distance) {
	if (angle<= 90) { position.x = (cos(angle)*distance); position.z = (sin(angle)*distance); }else
	if (angle<= 180) { position.x = -(cos(angle)*distance); position.z = (sin(angle)*distance); }else
	if (angle<= 270) { position.x = -(cos(angle)*distance); position.z = -(sin(angle)*distance); }else
	if (angle<= 360) { position.x = (cos(angle)*distance); position.z = -(sin(angle)*distance); } }



[Edited by - the_cyberlord on October 23, 2004 10:34:47 AM]

Share this post


Link to post
Share on other sites
Advertisement
OK, yeah, I know that, but I want to store directions in degrees too... so you could have an x and an y direction to store your 3D direction, but I see all those 3D modelers store it in 3 values, how does that work?

Share this post


Link to post
Share on other sites
Well two values aren't sufficient to store all rotation in 3D space. You can use three values to describe any rotation. The three values are basically how much it is rotated around an axis i.e. you'd have the rotation around the X, Y and Z axes stored using 3 values.

Share this post


Link to post
Share on other sites
Quote:
Original post by Mayrel
But if you want to store an orientation rather than just a direction, you may find that quaternions have a few technical benefits.

the difference between orientation and direction, in relation to this thread?

Share this post


Link to post
Share on other sites
Quote:
i thought matrices were best?
oh well....


Matrices are used when you need to apply a transformation (such as a rotation) to a point or a vector. You could store a rotation matrix to describe a rotation but whether this would be suitable or not depends on what you're actually trying to do.

Quote:
I know about rotateing around an axis, but I don't really see why you need three values...


There are three axes in a 3D system and thus you need 3 angles (i.e. 3 values).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!