How to find the Center Coordinate of Rectangle? [closed]

回眸只為那壹抹淺笑 提交于 2019-11-28 04:09:14
Prasad G
The center of rectangle is the mid point of the diagonal end points of rectangle. 
Here the midpoint is ( (x1 +x2)/2 ,(y1 + y2)/2 ).
that means xCenter = (x1 +x2)/2
           yCenter = (y1 + y2)/2

Let me know your code.

Center x =
x + 1/2 of width
Center y =
y + 1/2 of height

If you know the width and height already then you only need one set of coordinates.

Vinayak

We can calculate using mid point of line formula,

centre (x,y) =  new Point((boundRect.tl().x+boundRect.br().x)/2,(boundRect.tl().y+boundRect.br().y)/2)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!