I do not know how exactly it is called. Suppose there is a rectangle of this type: enter image description here

How to determine its center? The Cartesian coordinate system, the coordinates of each vertex are known (x, y). Or tell me which way to smoke.

  • one
    Make up the equations of the diagonals and then look for their point of intersection. Analytical geometry is able. The question is not about IT, IMHO at all ... - Vladimir Martyanov
  • Thanks, helped - Range
  • For average, which library is needed? - Vladilsav
  • @ Vladilsav calculation of the midpoint of the segment. You can write yourself, it's just a pseudo-name of the function - Range

1 answer 1

It should work for any parallelepiped:

xc = average(x0, x1, x2, x3) yc = average(y0, y1, y2, y3) 

Even 2 opposite vertices are enough:

 xc = average(x0, x1) yc = average(y0, y1) 
  • The only thing - I would fix x1, y1 in x2, y2 in the last formula :) - Harry