Home computickets Determine the center of the rectangle

Determine the center of the rectangle




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

How to determine his center? Decartian coordinate system, the coordinates of each vertex are known (x, y). Or tell me which way smoking.

Answer 1, Authority 100%

must work for any parallelepiped:

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

Even 2 opposite vertices are sufficient:

xc = average (x0, x1)
YC = Average (Y0, Y1)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions