Geometry  Right Triangles
Geometry  Right Triangles
(OP)
This isn't so much a programming problem (well most I see aren't), but it's a problem I'm trying to work out for a program and I'm not sure of it (probably just don't remember fully how to do it in a true logical way.
The problem (draw it out to imagine if you must): Say I have two points on a cartesian coordinate system. Having this information gives us some relative distances, which allows us to form a right triangle. I can take the x and y values and apply the Pythagorean Theorem to get the distance between the two points. All is fine here.
Now I want to draw a point that is between the two original points, where the distance on the xaxis is 1/2 the original distance of the points (basically in the middle), and the y distance is on the hypotenuse of the triangle described in the previous paragraph.
Basically:
Let a be the horizontal xaxis distance between the two points.
Let b be the vertical yaxis distance between the original two points.
let c be the hypotenuse or the actual distance between the two original points.
My initial assumption was that the xdistance for the old point and the new point in between is 0.5a. Therefore, since a new right triangle is formed within the bigger right triangle, the other distances of it would be 0.5b and 0.5c, but I wasn't sure since I'm not sure there's a provable arithmetic relationship as described.
Am I on the right track or is there something I'm missing to solve this problem?
The problem (draw it out to imagine if you must): Say I have two points on a cartesian coordinate system. Having this information gives us some relative distances, which allows us to form a right triangle. I can take the x and y values and apply the Pythagorean Theorem to get the distance between the two points. All is fine here.
Now I want to draw a point that is between the two original points, where the distance on the xaxis is 1/2 the original distance of the points (basically in the middle), and the y distance is on the hypotenuse of the triangle described in the previous paragraph.
Basically:
Let a be the horizontal xaxis distance between the two points.
Let b be the vertical yaxis distance between the original two points.
let c be the hypotenuse or the actual distance between the two original points.
My initial assumption was that the xdistance for the old point and the new point in between is 0.5a. Therefore, since a new right triangle is formed within the bigger right triangle, the other distances of it would be 0.5b and 0.5c, but I wasn't sure since I'm not sure there's a provable arithmetic relationship as described.
Am I on the right track or is there something I'm missing to solve this problem?
RE: Geometry  Right Triangles
CODE
point a is (x1, y1)
point b is (x2, y2)
then
distance ab = sqrt(sqr(x1x2)+sqr(y1y2))
point c (halfway between a and c) is ((x1+x2)/2, (y1+y2)/2)
You don't need half the distances between the x coordinates and ycoordinates, but half the sum of the respective coordinates (or mean values of x and y coordinates)
CODE
Y
^

4+ o a
 \
 \
 \ 8
++\++>X
1+ 3 o c 13
 \
 \
 \
 \
6+ o b

a = (3, 4)
b = (13, 6)
ab = sqrt(sqr(133)+sqr(64))
= sqrt(200)
= 14.142 (approx)
c = ((3+13)/2), (4 + (6))/2)
= (8, 1)
p5
RE: Geometry  Right Triangles
Y_{2}  Y_{1}
Y  Y_{1} = (  ) (X  X_{1})
X_{2}  X_{1}
Since you know that the target X is halfway along the X axis, it's value can be represented at (X_{1} + X_{2}) / 2, plug that in and solve for Y.
Y_{2}  Y_{1} X_{2} + X_{1}
Y  Y_{1} = (  ) (  X_{1})
X_{2}  X_{1} 2

Good Luck
To get the most from your TekTips experience, please read
FAQ1812886: How can I maximize my chances of getting an answer?
As a circle of light increases so does the circumference of darkness around it.  Albert Einstein