帮助制定三次缓动方程
我有以下一段代码
int steps = 10;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
console.log( "t " + t );
}
,它以线性方式输出数字,如下所示 { 0, 0.1, 0.2, ..., 0.9, 1.0 } 我想应用三次(输入或输出)缓动方程,以便输出数字增加或逐渐减少
更新
不确定我的实现是否正确,但我得到了预期的曲线
float b = 0;
float c = 1;
float d = 1;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
t /= d;
float e = c * t * t * t + b;
console.log( "e " + e );
//console.log( "t " + t );
}
I have the following piece of code
int steps = 10;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
console.log( "t " + t );
}
That out puts numbers in a linear fashion like this { 0, 0.1, 0.2, ..., 0.9, 1.0 } I would like apply the cubic (in or out) easing equation so the output numbers increase or decrease gradually
UPDATE
Not sure if my implementation if correct but I am getting curve as expected
float b = 0;
float c = 1;
float d = 1;
for (int i = 0; i <= steps; i++) {
float t = i / float(steps);
t /= d;
float e = c * t * t * t + b;
console.log( "e " + e );
//console.log( "t " + t );
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
EasIn 三次函数
EaseOut 三次函数
在这里您可以找到其他有用的方程: http://www.gizma.com/ easing/#cub1
将此代码放置一段时间,就像您之前所做的那样,您将得到输出立方递减的数字。
EasIn Cubic Function
EaseOut Cubic Function
Here you can find othere useful equations: http://www.gizma.com/easing/#cub1
Put this code in a while, as you've don before and you will have your output cubic decreasing numbers.
您可以使用 jQuery Easing 插件中的代码:
http://gsgd.co.uk/sandbox/jquery/easing/
You can use code from jQuery Easing plugin:
http://gsgd.co.uk/sandbox/jquery/easing/