//分300步进行移动动画
final int count = 300;
/**
* 要start 动画的那张图片的ImageView
* @param imageView
*/
private void startAnimation(final ImageView imageView) {
Keyframe[] keyframes = new Keyframe[count];
final float keyStep = 1f / (float) count;
float key = keyStep;
for (int i = 0; i < count; ++i) {
keyframes[i] = Keyframe.ofFloat(key, i + 1);
key += keyStep;
}
PropertyValuesHolder pvhX = PropertyValuesHolder.ofKeyframe("translationX", keyframes);
key = keyStep;
for (int i = 0; i < count; ++i) {
keyframes[i] = Keyframe.ofFloat(key, -getY(i + 1));
key += keyStep;
}
PropertyValuesHolder pvhY = PropertyValuesHolder.ofKeyframe("translationY", keyframes);
ObjectAnimator yxBouncer = ObjectAnimator.ofPropertyValuesHolder(imageView, pvhY, pvhX).setDuration(1500);
yxBouncer.setInterpolator(new BounceInterpolator());
yxBouncer.start();
}
final float a = -1f / 75f;
/**
* 这里是根据三个坐标点{(0,0),(300,0),(150,300)}计算出来的抛物线方程
*
* @param x
* @return
*/
private float getY(float x) {
return a * x * x + 4 * x;
}
package com.freesonfish;
public class ParabolaAlgorithm {
public static void main(String[] args) {
final float[][] points = { { 6, 15 }, { 15, 70 }, { 40, 60 } };
calculate(points);
}
/**
* a = (y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2)) / (x1 * x1 * (x2 -
* x3) + x2 * x2 * (x3 - x1) + x3 * x3 * (x1 - x2))
* b = (y1 - y2) / (x1 - x2) - a * (x1 + x2);
* c = y1 - (x1 * x1) * a - x1 * b;
*/
private static void calculate(float[][] points) {
float x1 = points[0][0];
float y1 = points[0][1];
float x2 = points[1][0];
float y2 = points[1][1];
float x3 = points[2][0];
float y3 = points[2][1];
final float a = (y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2))
/ (x1 * x1 * (x2 - x3) + x2 * x2 * (x3 - x1) + x3 * x3 * (x1 - x2));
final float b = (y1 - y2) / (x1 - x2) - a * (x1 + x2);
final float c = y1 - (x1 * x1) * a - x1 * b;
System.out.println("-a->" + a + " b->" +b + " c->" +c);
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有