本文整理匯總了Golang中rand.Rand.NormFloat64方法的典型用法代碼示例。如果您正苦於以下問題:Golang Rand.NormFloat64方法的具體用法?Golang Rand.NormFloat64怎麽用?Golang Rand.NormFloat64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rand.Rand
的用法示例。
在下文中一共展示了Rand.NormFloat64方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func (s *shadowMap) Init(corr_dist float64, Rgen2 *rand.Rand) {
nval := int(Field / corr_dist / shadow_sampling)
//fmt.Println(" shadowMap down Sampling ", shadow_sampling, " ", nval)
s.xcos = make([]float64, nval)
s.ycos = make([]float64, nval)
s.xsin = make([]float64, nval)
s.ysin = make([]float64, nval)
for i := 0; i < nval; i++ {
s.xcos[i] = Rgen2.NormFloat64()
//s.xcos[i] *= s.xcos[i]
s.ycos[i] = Rgen2.NormFloat64()
s.xsin[i] = Rgen2.Float64() * 2 * math.Pi
s.ysin[i] = Rgen2.Float64() * 2 * math.Pi
if s.xcos[i] < mval {
s.xcos[i] = 0
}
if s.ycos[i] < mval {
s.ycos[i] = 0
}
s.power += s.xcos[i] * s.xcos[i]
s.power += s.ycos[i] * s.ycos[i]
}
s.power = math.Sqrt(s.power) / shadow_deviance
for i := 0; i < nval; i++ {
s.xcos[i] /= s.power
s.ycos[i] /= s.power
}
s.smap = make([][]float32, mapsize)
for i := 0; i < mapsize; i++ {
s.smap[i] = make([]float32, mapsize)
x := (float64(i) - mapsize/2) / mapres
for j := 0; j < mapsize; j++ {
d := geom.Pos{x, (float64(j) - mapsize/2) / mapres}
s.smap[i][j] = float32(s.evalShadowFadingDirect(d))
//lets not have -Inf here
if s.smap[i][j] < 0.0000001 {
s.smap[i][j] = 0.0000001
}
}
}
}