Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于计算消失finalY点的疑惑. #52

Closed
pinkApple opened this issue Feb 6, 2017 · 4 comments
Closed

关于计算消失finalY点的疑惑. #52

pinkApple opened this issue Feb 6, 2017 · 4 comments

Comments

@pinkApple
Copy link

pinkApple commented Feb 6, 2017

childWith + changedView.getLeft() --> 不是很清楚具体的含义.

//这里是向左消失的计算.
finalY = yvel * (childWith + changedView.getLeft()) / (-xvel) + changedView.getTop()

我这里换成了这样.
因为 X,Y 消失消耗时间一致.
yvel / xvel = dy / dx
finalY = changedView.getTop() + dx * yvel / xvel;
也就是.
finalY = yvel * changedView.getRight() / (-xvel) + changedView.getTop();

测试后发现这种算法也能完美运行.但是finalY是不一样的..这就疑惑了..到底哪个才比较合适?

@xmuSistone
Copy link
Owner

childWith + changedView.getLeft()就是changedView.getRight
两个都对的。
finalY本身,在后续的代码中你也看到了,是做了一些妥协的,如果斜率太大,导致finalY太偏,所以代码中做了折中处理。

@pinkApple
Copy link
Author

pinkApple commented Feb 6, 2017

@xmuSistone
那向右移出呢, 测试也是2种都有效..
finalY = yvel * (childWith + changedView.getLeft()) / xvel + changedView.getTop();
这是我的向右正方向,
finalY = yvel * (allWidth - changedView.getLeft()) / xvel + changedView.getTop();

然后我的位移出屏也是测试有效:
正方向:
finalY = changedView.getTop() + dy * (allWidth - changedView.getLeft()) / dx;
反方向:
finalY = changedView.getTop() + dy * changedView.getRight() / -dx;

@xmuSistone
Copy link
Owner

allWidth的处理,我不大清楚。如果没错的话,你就继续用吧。
总的思路就是建立数学模型,根据当前位置和斜率,去计算左边缘和右边缘的坐标,这个怎么清晰怎么来;至于实现的方法,不必纠结,通往的目标的路不止一个。

@pinkApple
Copy link
Author

pinkApple commented Feb 6, 2017

好吧. 只是我觉得你向右的斜率计算可能和我的有点偏差.
你有时间可以试试我这个算法.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants