Bezier

manimlib/utils/bezier.py 这个文件中主要实现了和贝塞尔曲线、插值有关的函数


manimlib.utils.bezier.bezier(points)
返回由点集(锚点,控制点)确定的参数方程
贝塞尔曲线的次数由points中点的个数确定

manimlib.utils.bezier.partial_bezier_points(points, a, b)

Given an array of points which define a bezier curve, and two numbers 0<=a<b<=1, return an array of the same size, which describes the portion of the original bezier curve on the interval [a, b].

This algorithm is pretty nifty, and pretty dense.

给出贝塞尔曲线的点数组和两个01之间的数ab
返回一个大小相同的数组,该数组描述原始贝塞尔曲线在间隔[a,b]上的部分

manimlib.utils.bezier.interpolate(start, end, alpha)

线性插值


manimlib.utils.bezier.integer_interpolate(start, end, alpha)

alpha is a float between 0 and 1. This returns an integer between start and end (inclusive) representing appropriate interpolation between them, along with a “residue” representing a new proportion between the returned integer and the next one of the list.

For example, if start=0, end=10, alpha=0.46, This would return (4, 0.6).

整数插值,返回两个数,第一个为插值结果(整数),第二个为和线性插值相差的小数部分


manimlib.utils.bezier.mid(start, end)

返回(start+end)/2,start和end可以是任意类型


manimlib.utils.bezier.inverse_interpolate(start, end, value)

由插值的结果value,返回alpha


manimlib.utils.bezier.match_interpolate(new_start, new_end, old_start, old_end, old_value)
匹配插值,给出原插值范围old_start,old_end和结果old_value
返回以相同比例,插值范围为new_start,new_end的插值结果

manimlib.utils.bezier.get_smooth_handle_points(points)

给出一系列锚点points,返回经过points的平滑贝塞尔曲线的一系列控制点


manimlib.utils.bezier.diag_to_matrix(l_and_u, diag)

Converts array whose rows represent diagonal entries of a matrix into the matrix itself. See scipy.linalg.solve_banded

用矩阵以对角线形式填充矩阵
l,u为非零下上对角线数,diag为将以对角线形式填充的矩阵

manimlib.utils.bezier.is_closed(points)

检查曲线是否闭合(首尾锚点重合)