Permalink
Browse files

use local rand instead of global rand (thanks to tip from Sebastien B…

…inet)
  • Loading branch information...
kidoman committed Sep 24, 2013
1 parent 0e2c2c4 commit 5f16e4131faf9f712e716b04038523bd57bbca9b
Showing with 7 additions and 4 deletions.
  1. +7 −4 main.go
View
11 main.go
@@ -23,7 +23,10 @@ var art = []string{
" 11111 11 ",
}
var G []int = makeBV()
var (
G = makeBV()
r = rand.New(rand.NewSource(1337))
)
var (
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
@@ -55,9 +58,9 @@ func main() {
p := vector.Vector{X: 13, Y: 13, Z: 13}
for i := 0; i < 64; i++ {
t := a.Scale(rand.Float64() - 0.5).Scale(99).Add(b.Scale(rand.Float64() - 0.5).Scale(99))
t := a.Scale(r.Float64() - 0.5).Scale(99).Add(b.Scale(r.Float64() - 0.5).Scale(99))
orig := vector.Vector{X: 17, Y: 16, Z: 8}.Add(t)
dir := t.Scale(-1).Add(a.Scale(rand.Float64() + float64(x)).Add(b.Scale(float64(y) + rand.Float64())).Add(c).Scale(16)).Normalize()
dir := t.Scale(-1).Add(a.Scale(r.Float64() + float64(x)).Add(b.Scale(float64(y) + r.Float64())).Add(c).Scale(16)).Normalize()
p = sampler(orig, dir).Scale(3.5).Add(p)
}
@@ -76,7 +79,7 @@ func sampler(orig, dir vector.Vector) vector.Vector {
}
h := orig.Add(dir.Scale(dist))
l := vector.Vector{X: 9 + rand.Float64(), Y: 9 + rand.Float64(), Z: 16}.Add(h.Scale(-1)).Normalize()
l := vector.Vector{X: 9 + r.Float64(), Y: 9 + r.Float64(), Z: 16}.Add(h.Scale(-1)).Normalize()
r := dir.Add(bounce.Scale(bounce.DotProduct(dir.Scale(-2))))
b := l.DotProduct(bounce)

0 comments on commit 5f16e41

Please sign in to comment.