I am writing a javascript program to find the midpoint of the rectangle (diagonal lines which intersect in the middle) I have 8 co-ordinates (x1,y1) (x2,y2) (x3,y3) (x4,y4). How can i achieve this?
Asked
Active
Viewed 100 times
-3
-
Please share complate of your codes β Ivan Barayev Nov 19 '17 at 14:33
2 Answers
0
Just find the average of each coordinate. Because itβs a rectangle, you only need two coordinates. If x1, y1 is opposite x3, y3 then the midpoint is ((x1+x3)/2, (y1+y3)/2)

paper man
- 488
- 5
- 19
-
Can you kindly simplify more? Here is the list of my coordinates 134.2 = x1 174.1=x2 134.2=x3 174.1 =x4 741.4=y1 741.4=y2 725.6=y3 725.6=y4 β umzee Nov 19 '17 at 14:50
-
0
Midpoint of a triangle is the midpoint of each diagonal. So, the midpoint is:
x_mid = (x1 + x3)/2; // or (x2 + x4)/2
y_mid = (y1 + y3)/2; // or (y2 + y4)/2

OmG
- 18,337
- 10
- 57
- 90