Giter Club home page Giter Club logo

averagecurve's Introduction

AverageCurve

均速曲线路径

由于贝塞尔曲线和基本样条曲线插值形成的曲线路径不是均速的,在某些场景可能会影响效果。比如说鱼游动,一般的曲线插值会忽快忽慢,像下面这样子:

curve

变速的曲线不利于精确控制速度,所以需要做额外的计算,以符合要求。

在插值之前,额外计算到指定长度的t变量,实现均速曲线,处理之后的效果图:

curve

均速缓动曲线

前言:

物体的运动有时候需要由快变慢或者慢慢加快 这就需要叠加一个缓动曲线,游戏引擎预设的一些曲线都是初等函数叠加形成的,不能直观的感受到缓动曲线的变化趋势。 因此需要一个能够直接想象的到,并且方便自定义曲线的方式。

实现:

let rom = new CatmullRom(pts,1)
rom.lerp(t).y

接口 参数 说明
catmullRom=new CatmullRom(pts,usage) pts 曲线经过的点数组
usage 0:均速路径曲线
1:均速缓动曲线
catmullRom.lerp(t) t 插件比例,范围0-1,0:起点, 1:终点

matlab版本可以直观的观察曲线的轨迹,可以用来编辑曲线。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.