WPF C# Finding the corners of a transformed RectangleGeometry

怎甘沉沦 提交于 2019-12-02 21:35:15

问题


I'm trying to do some hit testing on a Rect I've drawn with several RenderTransforms pushed to the Canvas' DrawingContext. I've applied the same rotate/scale/translate transforms to a RectangleGeometry so I can get the bounds of the final drawing. However, the .Bounds property on RectangleGeometry returns the axis-aligned bounding box, while I need the oriented bounding box.

In short, I need some way to find the corners of the actual transformed rectangle so I can perform hit/collision testing on it.


回答1:


Apply the transforms to the points of the rectangle.



来源:https://stackoverflow.com/questions/4676750/wpf-c-sharp-finding-the-corners-of-a-transformed-rectanglegeometry

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!