mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 04:08:13 +02:00
removes equator, achieves uniform distribution of stars implementing rejection sampling, adds UNIX script header
This commit is contained in:
parent
408a21b515
commit
395e4a7852
1 changed files with 10 additions and 5 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
#
|
#
|
||||||
# gen_stars.py
|
# gen_stars.py
|
||||||
# interface
|
# interface
|
||||||
|
@ -12,7 +14,7 @@ from random import random,randint
|
||||||
from math import sqrt, hypot, atan2, pi, fmod, degrees
|
from math import sqrt, hypot, atan2, pi, fmod, degrees
|
||||||
from sys import argv,stderr
|
from sys import argv,stderr
|
||||||
|
|
||||||
hemisphere_only, equator, meridians= False, 1000, 1000
|
hemisphere_only, equator, meridians= False, 0, 1000
|
||||||
|
|
||||||
n_random = 100000
|
n_random = 100000
|
||||||
if len(argv) > 1:
|
if len(argv) > 1:
|
||||||
|
@ -50,10 +52,13 @@ for i in range(n_random):
|
||||||
g = max(0,min(255,w + randint(-20,60)))
|
g = max(0,min(255,w + randint(-20,60)))
|
||||||
b = max(0,min(255,w + randint(-10,100)))
|
b = max(0,min(255,w + randint(-10,100)))
|
||||||
# position
|
# position
|
||||||
x,y,z = random()*2-1,random(),random()*2-1
|
while True:
|
||||||
if not hemisphere_only:
|
x,y,z = random()*2-1,random(),random()*2-1
|
||||||
y = y*2-1
|
if not hemisphere_only:
|
||||||
l = sqrt(x*x + y*y + z*z)
|
y = y*2-1
|
||||||
|
l = sqrt(x*x + y*y + z*z)
|
||||||
|
if l <= 1.0:
|
||||||
|
break
|
||||||
x /= l; y /= l; z /= l
|
x /= l; y /= l; z /= l
|
||||||
xz = hypot(x,z)
|
xz = hypot(x,z)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue