circle inside triangle tangent points

Hello !
I have a problem and have not gotten anywhere.
I have to find the centerpoint of the circle and tangent points of the circle
Looking for any sugestions. Prefer not to use solve, but its acceptable.
Points of the triangle are :
ax=1,ay=1;
bx=5,by=2;
cx=4,cy=4;
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Only calculations ive gotten so far are these below. BUT they are very wrong or atleast i cant figure out how to solve this problem.
alfa=atand((ay-by)/(ax-bx))
beta=atand((ay-cy)/(ax-cx))
AC = sqrt((ax-cx)^2+(ay-cy)^2); %AC
AB = sqrt((ax-bx)^2+(ay-by)^2); %CB
CB = sqrt((bx-cx)^2+(by-cy)^2); %CB
s = (AB+AC+CB)/2
A = sqrt(s*(s-AB)*(s-AC)*(s-CB))
R = 2*(A)/(AB+AC+CB)
Fx = (bx+ax)/2; ,Fy = (by +ay)/2;
Ex = (cx+ax)/2; ,Ey = (cy +ay)/2;
Tx = (bx+cx)/2; ,Ty = (by +cy)/2;
theta=atand((ay-Ty)/(ax-Tx))
delta = ((ay-Ty)/(ax-Tx))
a=cosd(theta);
b=-cosd(delta);
c=sind(theta);
d=-sind(delta);
e=Tx-ax;
f=Ty-ay;
r=(d*e-b*f)/(a*d-b*c);
t=(a*f-c*e)/(a*d-b*c);
Px=ax+R*cosd(theta);
Py=ay+R*sind(theta);
Thank you for any help !

 採用された回答

Yongjian Feng
Yongjian Feng 2021 年 11 月 22 日

0 投票

This is more like a math problem, is it?
Can you compute two of the bisectors? They intercept right at the center of the circle, right?

4 件のコメント

pauli relanderi
pauli relanderi 2021 年 11 月 23 日
yes i could, but i would need to calculate the points first and i cant figure out how to calculate the 2 points.
Yongjian Feng
Yongjian Feng 2021 年 11 月 23 日
An easier way is to use the bisector theorem.
  1. You know the coordinates of A, B, and C, right? The vertices of the triangle.
  2. If you know the coordinats of B and C, you know the line of BC
  3. You know the length of AB and AC
  4. Assume that the bisector from angle A intercept BC at point H. Then BH/HC = AB/AC according to the bisector theorem. You can easily get the coordiate of H.
  5. Then you know AH.
  6. Do the same thing for another bisector. Say BG. Then find the intercept of BG and AH. It is the center of the circle.
Yongjian Feng
Yongjian Feng 2021 年 11 月 23 日
編集済み: Yongjian Feng 2021 年 11 月 23 日
Just basic math concepts:
ax=1;ay=1;
bx=5;by=2;
cx=4;cy=4;
% plot the triabgle
plot([ax bx cx ax], [ay by cy ay]);
hold on
ab = distance([ax ay], [bx by]);
ac = distance([ax ay], [cx cy]);
bc = distance([bx by], [cx cy]);
% d on bc. bisector theorem
dx = cx + (bx-cx)*ac/(ac + ab);
dy = cy + (by-cy)*ac/(ac + ab);
% e on ab. bisector theorem
ex = ax + (bx-ax)*ac/(ac+bc);
ey = ay + (by-ay)*ac/(ac+bc);
% ad and ce intercept at the center of the circle
[ox, oy] = polyxpoly([ax dx], [ay dy], [cx ex], [cy ey]);
% radius is the shortest distance from o to bc
radius = point_to_line([ox oy 0], [bx by 0], [cx cy 0]);
% G is O's projection on bc, and is the tangent point
[gx, gy] = point_project([ox oy], [cx cy], [bx by]);
% H is O's projection on ab, and is the tangent point
[hx, hy] = point_project([ox oy], [ax ay], [bx by]);
% I is O's projection on ac, and is the tangent point
[ix, iy] = point_project([ox oy], [ax ay], [cx cy]);
% now draw everything
plot([ax dx], [ay dy]);
plot([cx ex], [cy ey]);
% draw the circle
p = nsidedpoly(300, 'center', [ox oy], 'Radius', radius);
plot(p, 'FaceColor', 'r');
% three vertices of the triangle
text(ax, ay, 'A');
text(bx, by, 'B');
text(cx, cy, 'C');
% Note D and E are NOT the tangent points. They are the intercept of
% bisector
text(dx, dy, 'D');
text(ex, ey, 'E');
% O is the center of the circle
text(ox, oy, 'O');
% G, H, I are the tangent points.
text(gx, gy, 'G');
text(hx, hy, 'H');
text(ix, iy, 'I')
function dist = distance(p1, p2)
dist = sqrt((p1(1) - p2(1))^2+(p1(2) - p2(2))^2);
end
% compute the shortest distance from a point to a line
% https://www.mathworks.com/matlabcentral/answers/95608-is-there-a-function-in-matlab-that-calculates-the-shortest-distance-from-a-point-to-a-line
function d = point_to_line(pt, v1, v2)
a = v1 - v2;
b = pt - v2;
d = norm(cross(a,b)) / norm(a);
end
% project point c on to line ab. If d is the projection point on ab, then
% the distance cd must be the min.
function [dx, dy] =point_project(c, a, b)
ab_sq = (a(1) - b(1))^2 + (a(2) - b(2))^2;
alpha = -((a(2)-c(2))*(b(2)-a(2))+(a(1)-c(1))*(b(1)-a(1)))/ab_sq;
dx = a(1) + alpha*(b(1)-a(1));
dy = a(2) + alpha*(b(2)-a(2));
end
pauli relanderi
pauli relanderi 2021 年 11 月 24 日
Thank you man !
Helped me alot !
Glad to see that matlab commonity is this active !
Have a great rest of the week !

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2021 年 11 月 23 日

0 投票

You can find the circle using incircle in this FEX submission
Once you've done that, the computation of the tangent points is easy.

カテゴリ

ヘルプ センター および File ExchangeSparse Matrices についてさらに検索

製品

リリース

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by