如何在 FlattenPathGeometry 上的 Point.Y 处获取 Point.X - WPF
我有一个“FlattenedPathGeometry”,我希望能够从基于特定 Point.Y 的路径中获取特定 point.X
基本上我只需要任何给定 Y 处的 X 值。
提前感谢您的帮助。
I have a "FlattenedPathGeometry" and I want to be able to get a specific point.X from the path based on a specific Point.Y
Basically I just need the X value at any given Y.
Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GetFlattenedPathGeometry 给你返回一个多边形,所以基本上你必须考虑循环所有点并计算到你的点的最小距离。
如果您可以对几何形状或您的点做出任何假设,则可以加快搜索速度。
例如,如果路径很长,您可以通过将形状与以点为中心的圆形/正方形相交来加速。这限制了要测试的形状的点数,但要注意相交方法的成本非常高。您必须使用秒表来测量性能,才能了解您的情况下什么更好。
GetFlattenedPathGeometry gives you back a polygonal so basically you have to consider loop all the points and calculating the minimum distance to your point.
If you can make any assumption on the Geometry shape or your point, you can speed up the search.
For example if the path is very long, you can speed up by intersecting the shape with a circle/square centered in your point. This limit the number of points of the shape to test but be careful that the intersection method is very expensive. You'll have to measure the performances with a stopwatch to understand what's better in your case.