# Rotate points on sphere

I am drawing (green) points on a grid on a sphere, which works well using this code:

``````			phi = latitude;
theta = longitude;

position = {

x:radius * Math.cos(theta) * Math.sin(phi ),
y:radius * Math.sin(theta) * Math.sin(phi ),

};
``````

I just can’t work out how to rotate those points positions, ideally, I would like those to match the “north/south poles” of the white wireframe sphere as well, 90 degrees rotation

Can you please provide a little bit more context? Maybe the entire code as a live example?

Thank you for looking at this, I’ve set up a green points grid around a wireframe sphere, as you can see the “north/south poles” on the wireframe sphere are offset by 90 degrees. I know in theory I could just rotate the white wireframe sphere to match the “poles” on the green dots grid or all dots could be placed into an Object3D and then that one rotated, but I am trying to figure out how to align each points individual position? I hope I make sense… https://jsfiddle.net/blaze747/xx7mcrxb/38/

Hi!
Swap `y` and `z` values:

``````gridPosition = {

x:radius * Math.cos(theta) * Math.sin(phi ),
z:radius * Math.sin(theta) * Math.sin(phi )

};``````
2 Likes

Awesome thank you, so simple can’t believe I didn’t think of it That’s what I am after. Just out of interest, what would you do if you needed to rotate by let’s say just 10 degrees on that axis?

Do you mean something like that?
https://jsfiddle.net/prisoner849/ryppc2xe/

Yes, I was thinking along those lines as well, place those dots inside a 3d object and rotate the parent. Is that the most effective way? E.g. if I wanted to move all those dots on different trajectories around the wireframe sphere, create a parent container for each and rotate those?

I’m not sure that I understand your idea to use small spheres for such effect of points instead of using `THREE.Points()` with `THREE.BufferGeometry()`. But this is only my impression as I don’t know the final purpose and whole idea of that solution with spheres

Thank you for the tips, much appreciated, that’s my first three.js project, will check out points, wasn’t aware of those, are they more efficient, will they render/animate faster?

Using one object instead of several hundreds of objects. Well, yes, performance improvement

Cool, will check out the Points class