How to rotate object around a sphere

i know how to rotate an object around a sphere only on one plane using sin and cos but i have no idea how it 3d, any ideas?

You could create a point in the middle of the sphere that is connected to the object then just change its rotation.

A point on a sphere can be defined by two circles

You can therefore do something like:

cos(lon)*cos(lat), sin(lat), sin(lon)*cos(lat)

This formula looks kinda confusing but is really just

regularFormula = (cos(lon), 0, sin(long))
newFormula = regularFormula*cos(lat) + sin(lat)

The top regularFormula is what you already know
The new formula takes the Vector of the longitude circle at the specified point and, because its a unit vector, sets its new length/depth to the cos of the latitude
It then adds the height on to finalize it

Here are the actions taken, visualized:

  1. Find the normal longitudinal circle position
  2. Clip down length of Unit vector to desired latitudinal “depth”
  3. Move up the desired amount, resulting in final position (this is adequately described by the above image, just move from the tip of the cyan vector up sin(lat) to the tip of the green line, the desired position)

Some additional things:
In order to incorporate spheres of different sizes at different locations you could add some small things to the formula:
radius * ( cos(lon)*cos(lat), sin(lat), sin(lon)*cos(lat) ) + origin

What this would look like in lua code is along the lines of:

local position = radius **math.cos(lat), math.sin(lat), math.sin(lon)*math.cos(lat)) + origin

This would result in something like a longitude and latitude system