Plotting points evenly around an origin

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
wizzy
Messages
1
Reaction score
0
TL;DR
Can anyone help w/ how to plot the given number of points evenly around a sphere using the start and end degrees for phi and theta?
Say I have phi starting at 0 and ending at 360 degrees. Theta starts at 0 and ends at 360, and I input 10 points for phi and theta. I am trying to 3d plot phi * theta number of points around a center point.

I can plot a coordinate around a sphere using the following, which I think is correct. The axes I'm using on my project is x, y is up, and z is depth (in, out).

C++:
Real radius;
Radian theta;
Radian phi;

Vector3 result;
result.x = radius * Cos(phi) * Sin(theta);
result.z = radius * Sin(phi) * Sin(theta);
result.y = radius * Cos(theta);

But I don't understand how to get the number of points evenly distributed which should be, if I'm not mistaken, 100 points (phi's no. of points * theta's no. of points).
 
Last edited:
Physics news on Phys.org
Last edited:
Another way might be to consider a method used to generate random points on a sphere, which goes something like this;

The phi coordinate is selected by a random number Ua between 0 and 1;
phi = Ua * 2 * Pi.

The theta coordinate is determined by selecting another random number Ub between 0 and 1; then solving for theta = Acos( 1 – 2 * Ub ).

The x, y and z coordinates are then;
x = r * Sin( theta ) * Cos( phi )
y = r * Sin( theta ) * Sin( phi )
z = r * Cos( theta )

How could you generate an orderly sequence of Ua and Ub to cover the sphere with evenly spaced points ?
 
The Fibonacci Sphere distributes points evenly over a sphere.
Code:
Const As Integer n = 100
Const Double TwoPi = 8 * Atn( 1 )
Const As Double golden_ratio = ( Sqrt( 5.0 ) + 1.0 ) / 2.0
Const As Double golden_angle = ( 2 - golden_ratio ) * TwoPi

Type geog
    As Double lat, lon
    As Double x, y, z
End Type

Dim As geog a( 1 To n )

Dim As Double r = 1
Dim As Integer i
For i = 1 To n
    With a( i )
        .lat = Asin( 2 * i / ( n + 1 ) - 1 )
        .lon = golden_angle * i
        .x = r * Cos( .lat ) * Cos( .lon )
        .y = r * Cos( .lat ) * Sin( .lon )
        .z = r * Sin( .lat )
    End With
Next i