How to get X,Y,Z rotations of vertices on a sphere at the origin?
Posted
by Stoff81
on Stack Overflow
See other posts from Stack Overflow
or by Stoff81
Published on 2010-06-14T18:49:05Z
Indexed on
2010/06/14
18:52 UTC
Read the original article
Hit count: 242
Hey, I have a sphere in my game world and i would like to place a plane at each vertex on this sphere for debugging purposes. The planes should be orientated so that they lie flat against the sphere (perpendicular to the normals). The sphere is located at the origin, so all the vertices are relative to that.
If my thinking is correct, i should be able to do this using the positions of the vertices and some simple trigonometry. I have tried a few combinations but have had no joy yet. I would greatly appreciate some help on this. Thanks.
Here is my code:
float xRot = RADIANS_TO_DEGREES(sinf(vertex.x/PLANET_RADIUS));
float yRot = RADIANS_TO_DEGREES(cosf(vertex.y/PLANET_RADIUS));
glRotatef(xRot, 1.0, 0, 0);
glRotatef(yRot, 0, 1.0, 0);
© Stack Overflow or respective owner