3d movement around a sphere

Posted by user578954 on Stack Overflow See other posts from Stack Overflow or by user578954
Published on 2011-01-17T19:26:58Z Indexed on 2011/01/17 19:53 UTC
Read the original article Hit count: 192

Filed under:
|
|
|

Hey guys,

Im working in 3d for the first time in a long time. Basically im rotating a sphere and projecting x y z cords to place things on the surface based on the spheres X and Y rotation.

Heres the code im using:

    #define piover180 0.01745329252f

    GLfloat cosy = cos(yrot * piover180);

    island[i].x = rad * sin(xrot * piover180)* cosy;
    island[i].y = rad * sin(yrot * piover180);
    island[i].z = rad * cos(xrot * piover180) * cosy;

Problem is the Xrot positioning works fine but the Yrot placement always draw the objects into the north and south pole so they all cross at the top, which isnt correct for rotating. I need a way to solve this. Heres a picture to help explain

http://llllost.com/shuttle/47bcde62.jpg

Any help would be greatly appreciated, let me know if you need any more information

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c