29 lines
500 B
C#
29 lines
500 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Godot;
|
|
|
|
namespace Rokojori
|
|
{
|
|
|
|
public class BernsteinPolynom
|
|
{
|
|
public static float Compute( int degree, int i, float t )
|
|
{
|
|
var result = 0f;
|
|
|
|
var n = degree;
|
|
|
|
var weight = BinomoalCoefficent.Compute( n, i );
|
|
|
|
var inverse = Mathf.Pow( 1 - t, n - i );
|
|
var forward = Mathf.Pow( t, i );
|
|
|
|
result += inverse * forward * weight;
|
|
|
|
return result;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} |