Permalink
Browse files

do not use math.Pow to compute ** 99, and only compute p if required

  • Loading branch information...
kidoman committed Sep 26, 2013
1 parent 527e083 commit 6bc7a2c4c635c269d364fddd68fa999877a0c98c
Showing with 9 additions and 2 deletions.
  1. +9 −2 main.go
View
11 main.go
@@ -165,8 +165,6 @@ func sampler(orig, dir vector.Vector) vector.Vector {
sf = 1.0
}
p := math.Pow(l.DotProduct(r.Scale(sf)), 99)
if st == missDownward {
h = h.Scale(0.2)
fc := vector.Vector{X: 3, Y: 3, Z: 3}
@@ -176,6 +174,15 @@ func sampler(orig, dir vector.Vector) vector.Vector {
return fc.Scale(b*0.2 + 0.1)
}
p := l.DotProduct(r.Scale(sf))
p33 := p * p // p ** 2
p33 = p33 * p33 // p ** 4
p33 = p33 * p33 // p ** 8
p33 = p33 * p33 // p ** 16
p33 = p33 * p33 // p ** 32
p33 = p33 * p // p ** 33
p = p33 * p33 * p33
return vector.Vector{X: p, Y: p, Z: p}.Add(sampler(h, r).Scale(0.5))
}

0 comments on commit 6bc7a2c

Please sign in to comment.