Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Geometry - Right Triangles

Geometry - Right Triangles

Geometry - Right Triangles

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 x-axis 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.

Let a be the horizontal x-axis distance between the two points.
Let b be the vertical y-axis 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 x-distance 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


 point a is (x1, y1)
 point b is (x2, y2)
 distance ab = sqrt(sqr(x1-x2)+sqr(y1-y2))
 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 y-coordinates, but half the sum of the respective coordinates (or mean values of x- and y- coordinates)



  4+  o a
   |   \
   |    \
   |     \ 8
 -1+  3    o c  13
   |        \
   |         \
   |          \
   |           \
 -6+            o b

 a = (3, 4)
 b = (13, -6)
ab = sqrt(sqr(13-3)+sqr(-6-4))
   = sqrt(200)
   = 14.142 (approx)

 c = ((3+13)/2), (4 + (-6))/2)
   = (8, -1)


RE: Geometry - Right Triangles

Assuming that it's not a vertical line, the approach that I would take is to first determine the equation of the line that contains the two original points.  The substitute the known value of x and solve for y.

               Y2 - Y1
Y - Y1 = ( --------- )  (X - X1)
               X2 - X1

Since you know that the target X is halfway along the X axis, it's value can be represented at (X1 + X2) / 2, plug that in and solve for Y.

               Y2 - Y1        X2 + X1
Y - Y1 = ( --------- )  (----------  -  X1)
               X2 - X1           2

Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886: 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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close