首页 > 编程知识 正文

会计中的插值法,三次样条插值函数例题

时间:2023-05-05 16:47:32 阅读:208955 作者:1502

static function SmoothStep(from:float,to:float,t:float):float

Description描述

Interpolates between min and max and eases in and out at the limits.

和Lerp类似,在最小和最大值之间的插值,并在限制处渐入渐出

using System.Collections;
using System.Collections.Generic;
using rxdhm;

public class Example : MonoBehaviour
{
    // Minimum and maximum values for the transition.
    float minimum = 10.0f;
    float maximum = 20.0f;

    // Time taken for the transition.
    float duration = 5.0f;

    float startTime;
    int number = 0;

    void Start()
    {
        // Make a note of the time the script started.
        startTime = Time.time;
    }

    void Update()
    {
        // Calculate the fraction of the total duration that has passed.
        float t = (Time.time - startTime) / duration;
        transform.position = new Vector3(Mathf.SmoothStep(minimum, maximum, t), 0, 0);
    }
}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。