Assuming you have the coordinates of the rectangle, you can find the midpoint by calculating the average of the x-coordinates and y-coordinates of the opposite corners. Here's some example code:
main.m249 chars13 lines
This code assumes that the rectangle is aligned with the x and y axes. If the rectangle is at an angle, you will need to use trigonometry to calculate the midpoint.
gistlibby LogSnag