How to Find the Center of a Rectangle: X & Y Coordinates
To get the center x and y coordinates of a rectangle, you need to know the coordinates of its top left corner (x1, y1) and its bottom right corner (x2, y2).
The center x coordinate can be calculated as (x1 + x2) / 2, and the center y coordinate can be calculated as (y1 + y2) / 2.
So the formula to get the center coordinates of a rectangle is:
center_x = (x1 + x2) / 2 center_y = (y1 + y2) / 2
原文地址: https://www.cveoy.top/t/topic/m36O 著作权归作者所有。请勿转载和采集!