メインコンテンツ

Uniform Sphere Sampling with Fibonacci Lattice

R2026b

This example shows how to obtain uniform sampling along the surface of a unit sphere using a Fibonacci lattice.

Create and plot a unit sphere. The sphere function creates a uniform sampling along a grid in spherical coordinates. This sampling in Cartesian coordinates is not uniform.

figure
sphere
axis equal

Figure contains an axes object. The axes object contains an object of type surface.

To obtain a uniform sampling in Cartesian coordinates, first generate a Fibonacci lattice of 500 points on a unit sphere.

n = 500;
indices = (0:n)';

The Fibonacci lattice provides uniform point distribution by spacing points along a spiral using the golden ratio.

goldenRatio = (1 + sqrt(5))/2;

Compute polar angle mapping points uniformly along the z-axis from 1 to -1.

phi = acos(1 - 2*indices/n);

Compute azimuthal angle using the golden ratio spacing.

theta = 2*pi*indices/goldenRatio;

Convert spherical coordinates to Cartesian coordinates.

x = sin(phi).*cos(theta);
y = sin(phi).*sin(theta);
z = cos(phi);

Compute the convex hull of the set of points on the sphere.

k = convhull(x,y,z);

Plot the result.

figure
trisurf(k,x,y,z);
axis equal

Figure contains an axes object. The axes object contains an object of type patch.