Jump to content
  • Advertisement
Sign in to follow this  

Logo 3D

This topic is 4698 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

I'm working on my current project called Logo 3D, which is a 3D version of Logo(that turtle). However, there is a problem about tracking the routine of the turtle. The following is a code segment of the 'forward function' in Logo 2D:
forward(int distance) {
    //calculate the new position:
So what does the 3D one look like?

Share this post

Link to post
Share on other sites
You'll have to use spherical coordinates for that one...
They are 3 scalar coordinates; 'rho' is the distance from the origin, 'phi' is the longitude of the point in [0, 2pi] and 'theta' is the latitude angle in [-pi/2, pi/2]

To convert from spherical to cartesian and vice versa...

x = rho*cos(phi)*cos(theta)
y = rho*sin(phi)*cos(theta)
z = rho*sin(theta)
rho = sqrt(x2 + y2 + z2)
phi = atan2(y,x)
theta = atan2(z,sqrt(x2+y2))

If you can't use atan2, use any implementation of atan() that takes into account the quadrant in which the point lies. That means, don't use a version of atan() that returns results in the range [-pi/2, pi/2]. In that case, you'll have to calculate the angles as such: (at least the 'phi' one)

phi = atan(y/x)
theta = atan(z/sqrt(x2+y2))

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!