Re: How to compute triangle base/altitude intersection



Richard Heathfield wrote:
Balabek@xxxxxxxxx said:


Hi,

Hope you can help me solve this problem.

Suppose I have a triange ABC. I have altitude passing through vertice
C, and it intersects line AB or extension of line AB at point D.

Given coordinates of points A, B, and lengths of line segments AC, BC,
how would you calculate coordinates of point D?


Draw a circle of diameter AC about A. Draw a circle of diameter BC about B. If the circles only touch each other tangentially, the triangle is actually degenerate (it's just a line), and the point where they touch is D. If they don't touch at all, there is no solution. Otherwise, they intersect at two points, C1 and C2, and the coordinates of D are at


Correct up to here I think. Draw segment AB at 0 on the y-axis
with C being a positive on the y axis (anywhere, doesn't really
matter) and *then* apply the above steps.

After doing so, you should have C1 and C2 (as Richard said).
The X component of either C1 or C2 (should be equal to each
other) is the X component of point D; the y component of D
is, of course, 0.

As long as you are allowed to have AB parallel to the x-axis
that should work. If AB can be a vector with any coordinates
relative to the x-axis it gets a little harder (you'd then
have to translate the basis so that AB is parallel to x-axis,
perform the aforementioned steps and then translate back).

If ABC define a plane in xyz, point D will then be a point
*on* the plane and definately won't be an extension of AB
(will have to lie on AB), however I don't really have a
solution off-hand for this one (I suspect that the question
won't make sense in xyz space anyway).

((C1.x + C2.x) / 2, (C1.y + C2.y) / 2)


I do have a way to compute it, but I just can't shake away this feeling
that it is not very efficient.


Measure. If your existing solution is fast *enough*, leave well alone.


Two rules of optimisation:
Rule 1:
Don't optimise.
Rule 2 (for experts only):
Don't optimise yet.

goose,
.



Relevant Pages