Пример #1
0
func bezier (t float64, n uint, xs, ys []float64) (float64, float64) {
//
  var x, y float64
  for i:= uint(0); i <= n; i++ {
    a:= float64(ker.Binomial (n, i)) * p (1 - t, 1, n - i) * p (t, 1, i)
    x += a * xs[i]
    y += a * ys[i]
  }
  return x, y
}
Пример #2
0
func bezier(x, y []int, m, n, i uint) (int, int) {
	//
	a, b := float64(i)/float64(n), float64(n-i)/float64(n)
	t, t1 := make([]float64, m), make([]float64, m)
	t[0], t1[0] = 1.0, 1.0
	for k := uint(1); k < m; k++ {
		t[k], t1[k] = a*t[k-1], b*t1[k-1]
	}
	for k := uint(0); k < m; k++ {
		w := float64(ker.Binomial(m-1, k)) * t[k] * t1[m-1-k]
		a += w * float64(x[k])
		b += w * float64(y[k])
	}
	return int(a + 0.5), int(b + 0.5)
}
Пример #3
0
// Returns n over k, the number of k-element-subsets of an n-element-set.
func Binom(n, k uint) uint { return ker.Binomial(n, k) }