`mix`的函数描述似乎有误

mix 函数的描述为 x\times a + (1-a)\times y,但是实际的代码是 x * (1.0 - a) + y * a

这应该算是个笔误?

@ti.func
def mix(x, y, a):
    """Performs a linear interpolation between `x` and `y` using
    `a` to weight between them. The return value is computed as
    :math:`x\times a + (1-a)\times y`.

    The arguments can be scalars or :class:`~taichi.Matrix`,
    as long as the operation can be performed.

    This function is similar to the `mix` function in GLSL.

    Args:
        x (:mod:`~taichi.types.primitive_types`, :class:`~taichi.Matrix`): Specify
            the start of the range in which to interpolate.
        y (:mod:`~taichi.types.primitive_types`, :class:`~taichi.Matrix`): Specify
            the end of the range in which to interpolate.
        a (:mod:`~taichi.types.primitive_types`, :class:`~taichi.Matrix`): Specify
            the weight to use to interpolate between x and y.

    Returns:
        (:mod:`~taichi.types.primitive_types`, :class:`~taichi.Matrix`): The linear
            interpolation of `x` and `y` by weight `a`.

    Example::

        >>> x = ti.Vector([1, 1, 1])
        >>> y = ti.Vector([2, 2, 2])
        >>> a = ti.Vector([1, 0, 0])
        >>> ti.math.mix(x, y, a)
        [2.000000, 1.000000, 1.000000]
        >>> x = ti.Matrix([[1, 2], [2, 3]], ti.f32)
        >>> y = ti.Matrix([[3, 5], [4, 5]], ti.f32)
        >>> a = 0.5
        >>> ti.math.mix(x, y, a)
        [[2.000000, 3.500000], [3.000000, 4.000000]]
    """
    return x * (1.0 - a) + y * a

在API文档中也是相同的描述
https://docs.taichi-lang.org/api/taichi/math/mathimpl/#taichi.math.mathimpl.mix

感谢指出,这个错误已经修了,下次 release 后会更新过来

1 个赞