I am attaching a general solution with some R code.
- We need to a system of equations (with two unknowns) that are logically independent.
- The area of a triangle can be computed using the sides (Heron Area) and can also be compared to the area formula using vertices of the triangle.
- The distance formula mentioned above can be used twice (AC and BC) and these equations can be subtracted.
- Understanding the nature of the problem, there will be two solutions: C and C'
heronAreaTriangle = function (AB,BC,AC)
{
s = 1/2 * (AB+BC+AC); # semi-perimeter
Area = sqrt(s * (s-AB) * (s-BC) * (s-AC) );
Area; # returns Area
}
findTrianglePointC = function(AB,BC,AC, x_a,y_a, x_b,y_b)
{
M = matrix(0,ncol=2,nrow=2);
Area = heronAreaTriangle(AB,BC,AC);
dy = y_a-y_b; dx = x_a - x_b; dxy = x_a*y_b - y_a * x_b;
y_c = ( dxy + dy * x_c - 2 * Area ) / dx;
x_c = ( (BC^2-AC^2) - x_b^2 - y_b^2 + x_a^2 + y_a^2 - 2*dy*y_c) / (2*dx);
M[1,1]=x_c;
M[1,2]=y_c;
y_c = ( dxy + dy * x_c + 2 * Area ) / dx;
x_c = ( (BC^2-AC^2) - x_b^2 - y_b^2 + x_a^2 + y_a^2 - 2*dy*y_c) / (2*dx);
M[2,1]=x_c;
M[2,2]=y_c;
result = as.data.frame(M);
colnames(result) = c("c_x","c_y");
# result;
list("x_a"=x_a,"y_a"=y_a, "x_b"=x_b,"y_b"=y_b, "AB"=AB,"BC"=BC,"AC"=AC, "Area"=Area, "result"=result);
}
Usage:
findTrianglePointC(AB,BC,AC, x_a,y_a, x_b,y_b);
findTrianglePointC(5,4,3, 0,0, 5,0); # the example above
result = findTrianglePointC(5,4,3, 0,0, 5,0);
result;
result$result;
result$result[1,];
result$result[2,];
as.numeric(result$result[2,]);
result$result[1,]$c_x;
result$result[1,]$c_y;
Output:
> findTrianglePointC(5,4,3, 0,0, 5,0); # the example above
$x_a
[1] 0
$y_a
[1] 0
$x_b
[1] 5
$y_b
[1] 0
$AB
[1] 5
$BC
[1] 4
$AC
[1] 3
$Area
[1] 6
$result
c_x c_y
1 1.8 2.4
2 1.8 -2.4
The logic is correct, although possible errata may exist (I haven't tried it on several cases).
Sources:
More verbosity about the logic that is simplified above:
determinateAreaTriangle = function (x_a,y_a, x_b,y_b, x_c,y_c)
{
# https://people.richland.edu/james/lecture/m116/matrices/area.html
# https://people.richland.edu/james/lecture/m116/matrices/applications.html
M = matrix(c(x_a,y_a,1, x_b,y_b,1, x_c,y_c,1), ncol=3);
A = abs( 1/2 * det(M) );
A = abs( 1/2 * (x_b*y_c - x_c*y_b - x_a*y_c + x_c*y_a + x_a*y_b - x_b *y_a ) ); # by-hand computation
A; # returns Area
}
# given points A (x_a,y_a) B (x_b,y_b) and lengths of sides AB, BC, AC
# find coordinates for C (x_c, y_c) which should return two possible answers
# geometry of two intersection circles from two vertices of triangle = two solutions
# heronEquation for area, find numeric value
Area = heronAreaTriangle(AB,BC,AC);
# use determinateAreaTriangle as an equation to help solve simultaneous system
# Area = abs( 1/2 * (x_b*y_c - x_c*y_b - x_a*y_c + x_c*y_a + x_a*y_b - x_b *y_a ) );
# Area = 1/2 * abs ( x_a*y_b - x_b * y_a + x_c * (y_a-y_b) + y_c * (x_b-x_a) );
# 2*Area = abs ( x_a*y_b - y_a * x_b + x_c * (y_a-y_b) - y_c * (x_a - x_b) );
dy = y_a-y_b; dx = x_a - x_b; dxy = x_a*y_b - y_a * x_b; # deltas of x,y, and innerproduct?
#2*Area = abs ( dxy + x_c * (dy) - y_c * (dx) );
# y_c = ( dxy + dy * x_c - 2 * Area ) / dx;
# y_c = ( dxy + dy * x_c + 2 * Area ) / dx;
# distance formula (circle definition)
# BC = sqrt( (x_c-x_b)^2 + (y_c-y_b)^2 );
# BC2 = (x_c-x_b)^2 + (y_c-y_b)^2; # squared is circle formula?
# AC = sqrt( (x_c-x_a)^2 + (y_c-y_a)^2 );
# AC2 = (x_c-x_a)^2 + (y_c-y_a)^2; # squared is circle formula?
# subtract BC2-AC2
# BC2-AC2 = x_b^2 + y_b^2 - x_a^2 - y_a^2 + 2*x_c * (x_a - x_b) + 2*y_c* (y_a-y_b);
# BC2-AC2 = x_b^2 + y_b^2 - x_a^2 - y_a^2 + 2*x_c * (dx) + 2*y_c* (dy);
# solve for x_c in distance formula (for each y_c)
# x_c = ( (BC^2-AC^2) - x_b^2 - y_b^2 + x_a^2 + y_a^2 - 2*dy*y_c) / (2*dx);
# https://people.richland.edu/james/lecture/m116/matrices/applications.html
# A (-2,2), B (1,5) and C (6,-1) ... maybe C' (-1,13)
# x_a = -2; y_a = 2; x_b = 1; y_b = 5; x_c = 6; y_c = -1;
# AB=3*sqrt(2); BC = sqrt(61); AC=sqrt(73);
# https://math.stackexchange.com/questions/543961/determine-third-point-of-triangle-when-two-points-and-all-sides-are-known
# A (0,0), B (5,0) and C (9/5,12/5) ... maybe C' (9/5,-12/5)
# x_a = 0; y_a = 0; x_b = 5; y_b = 0; x_c = 9/5; y_c = 12/5;
# AB=5; BC = 4; AC=3;