Matthias
Matthias

Reputation: 4677

Distribute points evenly on a unit hemisphere

To distribute point evenly on a unit sphere, the answer uses a Fibonacci spiral that maintains constant surface area.

Is it now possible to use a similar method to distribute points evenly on a unit hemisphere without rejecting points? Taking the absolute value like

cos_theta = abs(((i * offset) - 1) + (offset / 2))

does not work as it seems to cluster the points in pairs.

Upvotes: 3

Views: 2084

Answers (1)

Vincent van der Weele
Vincent van der Weele

Reputation: 13187

The y values loop from -1+1/samples to 1-1/samples by means of the for loop:

for i in range(samples):
    y = ((i * offset) - 1) + (offset / 2)

You want to loop from 0+1/samples to 1-1/samples. Simply skip the first sample/2 iterations:

for i in range(samples / 2, samples):
    y = ((i * offset) - 1) + (offset / 2)

Of course it is cleaner to now rewrite the expressions a bit, such that you loop from 0 to samples' again, but this should be a good starting point for more refactoring.

Upvotes: 4

Related Questions