Explanation of a formula for spherical 3d tag cloud

254 Views Asked by At

I am not an expert in mathematics, I am only a young programmer. I am trying to construct a spherical tag cloud and I've found this formula:

for i,t in enumerate(tags)
    phi = acos((2* (i+1) -1) / tag_num -1)
    theta = sqrt(tag_num * pi) * phi

    x = radius * cos(theta) * sin(phi)
    y = radius * sin(theta) * sin(phi)
    z = radius * cos(phi)

    t.setPosition(x,y,z)

and it works fine. but I thought, for a spherical disposition, have to do 2 nested for: one for latitude and one for longitude. What kind of formula do I use in these codes? Can you explain me what this acos and sqrt do?