如何在Android中找到路径中的所有点? [英] How do I find all the Points in a Path in Android?
问题描述
不久前我问了一个问题,看看我是否能够在路径中找到一对特定的点;但是,这次我想知道是否有办法知道路径中的所有点?(我找不到这样做的方法,这很不幸,因为 Java 提供了一种方法,而 Android 没有?)
Awhile back I asked a question to see if I was able to find a pair of specific points in a path; however, this time I want to know if there is a way to know all points in a path? (I couldn't find a method that did so, which is unfortunate because Java provides a way to do this, just not Android?)
我问这个的原因是因为我有多个几何图形,我想比较这些点以查看它们相交的位置.
The reason I ask this is because I have multiple geometric graphs and I want to compare the points to see where they intersect.
感谢任何有用的回复
推荐答案
如果您已经创建了 Path
,这意味着在您的代码的某些点,您知道确切的 (Geo) 点.你为什么不把这个点放在 ArrayList
或类似的东西上?
If you have created a Path
that means that in some point of your code, you know the exact (Geo)point. Why don't you put this point(s) on a ArrayList
or something similar?
例如在做之前:
path.lineTo(point.x, point.y);
你可以:
yourList.add(point);
path.lineTo(point.x, point.y);
然后你可以从 ArrayList
得到你所有的点数.请注意,您可以利用增强的 For 循环语法ArrayList
的执行速度提高了三倍.
And later you can get all your points from the ArrayList
.
Note you that you can take advantage of the Enhanced For Loop Syntax of ArrayList
that execute up to three times faster.
这篇关于如何在Android中找到路径中的所有点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!