using System.Collections; using System.Collections.Generic; using Godot; namespace Rokojori { public class CubicBezier { public static float Compute( float t, float p0, float p1, float p2, float p3 ) { var bp0 = ( 1 - t ) * ( 1 - t ) * ( 1 - t ); var bp1 = 3 * ( 1 - t ) * ( 1 - t ) * t; var bp2 = 3 * ( 1 - t ) * t * t; var bp3 = t * t * t; return p0 * bp0 + p1 * bp1 + p2 * bp2 + p3 * bp3; } public static Vector2 Compute( float t, Vector2 p0, Vector2 p1, Vector2 p2, Vector2 p3 ) { var bp0 = ( 1 - t ) * ( 1 - t ) * ( 1 - t ); var bp1 = 3 * ( 1 - t ) * ( 1 - t ) * t; var bp2 = 3 * ( 1 - t ) * t * t; var bp3 = t * t * t; return p0 * bp0 + p1 * bp1 + p2 * bp2 + p3 * bp3; } public static Vector3 Compute( float t, Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3 ) { var bp0 = ( 1 - t ) * ( 1 - t ) * ( 1 - t ); var bp1 = 3 * ( 1 - t ) * ( 1 - t ) * t; var bp2 = 3 * ( 1 - t ) * t * t; var bp3 = t * t * t; return p0 * bp0 + p1 * bp1 + p2 * bp2 + p3 * bp3; } } }