# 3d geometry: triangle 2 points known, find 3rd point

I have a 3d triangle ABC. Lengths AB, BC, and AC are known. Coordinates of points A and B are known. Point C only the y value of the coordinate is known.

I believe there are 2 points that can satisfy the above constraints, I just can't find a method to derive them. If it simplifies calculations, either A or B can be located at (0,0,0).

I do not care how it can be solved, as long as I can implement it in Ruby.

Any guidance will be greatly appreciated.

-

If you have the points $A$ and $B$ and the distance from $C$ to them, that is $AC$ and $BC$, for sure your point $C$ must belong on the intersection of two spheres, centered at $A$ and $B$, with radius $AC$ and $BC$, respectively. But this intersection should be a circle. Then you have to use other information about $C$ to determine it (its $y$-coordinates, for example).

Edit: as observed by Zev Chonoles, this does not work if the circle of intersection is contained on the $xz$-plane.

-
I think you should mention explicitly that if the circle lies in the $xz$-plane (i.e. the $y$-coordinate of every point on the circle is the same) then knowing the $y$-coordinate provides no information and there will be infinitely many points meeting the constraints, and also that it is possible there is only one point meeting the constraints. – Zev Chonoles Jan 2 '13 at 22:06
my reply was too long for a comment, I had to post it as a separate answer. – Scott Jan 5 '13 at 20:18

Okay, using Sigurs advice, I can solve for x and z of point C. The code below seems to work correctly in my application. I verified the output of a few points with my CAD software.

Is there a cleaner method, maybe using Matrix or Vector math? The equations are extremely long. I broke the equation for c.z up into a few parts to try and reduce typos.

(c.x - a.x)^2 + (c.y - a.y)^2 + (c.z - a.z)^2 = ac^2
a = [0, 0, 0]
x^2 + y^2 + z^2 = AC^2

(c.x - b.x)^2 + (c.y - b.y)^2 + (c.z - b.z)^2 = bc^2


known variables

b.x, b.y, b.z, c.y, ab, ac, bc


find c.x and c.z

below is my equations coded in ruby that has passed my unit tests so far.

c.x = ( ac**2 - bc**2 + b.x**2 + b.y**2 - 2*c.y*b.y + b.z**2 - 2*c.z*b.z ) / (2*b.x)

aa = 4*ac**2*b.z - 4*bc**2*b.z + 4*b.x**2*b.z + 4*b.y**2*b.z - 8*c.y*b.y*b.z + 4*b.z**3
bb = 2*ac**2*bc**2 - ac**4 + 2*ac**2*b.x**2 - 2*ac**2*b.y**2 + 4*ac**2*b.y*c.y + 2*ac**2*b.z**2 - bc**4 + 2*bc**2*b.x**2 + 2*bc**2*b.y**2 - 4*bc**2*b.y*c.y + 2*bc**2*b.z**2 - b.x**4 - 2*b.x**2*b.y**2 + 4*b.x**2*b.y*c.y - 2*b.x**2*b.z**2 - 4*b.x**2*c.y**2 - b.y**4 + 4*b.y**3*c.y - 2*b.y**2*b.z**2 - 4*b.y**2*c.y**2 + 4*b.y*b.z**2*c.y - b.z**4 - 4*b.z**2*c.y**2
c.z = 4*b.x**2 * ( ((aa) / 8*b.x**2) + (Math.sqrt(bb) / (2*b.x)) ) / (4*b.x**2 + 4*b.z**2)

-