Draw a rectangle arround a polygon when given in certain angle

时光总嘲笑我的痴心妄想 提交于 2019-12-04 21:41:04

This is very similar to finding a bounding box, which is not rotated.

If your angle of rotation is alpha, then take the unit vectors along Ox and Oy and rotate them by this angle alpha to get unit vectors X and Y. Now you are looking for the bounding box with respect to X,Y.

For each point (represented by a vector) P in your set you can get the oriented projection by taking the dot product: Px = P.X and Py = P.Y

If

Mx is the max Px, mx is the min Px.

My is the max Py, my is the min Py.

then this is your bounding rectangle.

I am not sure what representation of it you need, but say its vertices would be:

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