I have a python app where I need to find a position that is exactly in the middle between two screen coordinates, but I can't seem to find an algorithm to do this. How can this be accomplished?
+5
A:
This is elementary geometry:
- point1(x1,y1)
- point2(x2,y2)
- point_in_the_middle(x=(x1+x2)/2,y=(y1+y2)/2)
Or did you mean something else ?
dmckee: Yes dear! :)
ldigas
2009-02-06 20:49:39
+1 for codeishness, even if tehvan beat you to the punch, but please format it!
dmckee
2009-02-06 20:51:23
+1
A:
The middle point (C) should be the average of the two points (A, B):
Cx = (Ax + Bx) / 2
Cy = (Ay + By) / 2
Assaf Lavie
2009-02-06 20:50:09
+2
A:
You want to use find the midpoint of a line Here is a little article to explain the math behind it. http://regentsprep.org/regents/math/midpoint/Lmidpoint.htm
Basically you're algorithm will look like this
midX = (x1 + x2) / 2
midY = (y1 + y2) / 2
CalvinR
2009-02-06 20:50:13