i have to draw an incircle in a triangle.
5 ビュー (過去 30 日間)
古いコメントを表示
i have to draw an incircle of a triangle, for that i have made an traingle... but now, how to plot an incicle in it.
clc
clear
p1=[2 0 0];
p2=[0 2 0];
p3=[0 0 2];
% Plot triangle using 'patch'
figure('color','w')
h=patch('Faces',1:3,'Vertices',[p1;p2;p3]);
set(h,'FaceColor','r','EdgeColor','k','LineWidth',2,'FaceAlpha',0.5)
axis equal vis3d
view([100 100])
xlabel('x','FontSize',20)
ylabel('y','FontSize',20)
zlabel('z','FontSize',20)
0 件のコメント
回答 (1 件)
Swatantra Mahato
2020 年 11 月 20 日
Hi Saurabh,
Assuming you have calculated the incentre and inradius for the incircle, you can plot the incircle by using the parametric equations for a circle in 3D space and using the "plot3" function.
An example workflow is shown below (here "r" is the inradius and "in" is the vector representing the incentre)
V=[2,2,2]; %the normal to the plane of the triangle
V=V/norm(V); % unit vector for the normal
A=(p1-in)/norm(p1-in); % a unit vector on the plane passing through center of the circle
B=cross(A,V); % a vector perpendicular to A and in the plane of the triangle. A and B act as the axes
th=0:0.01:2*pi;
x=in(1)+r*cos(th)*A(1)+r*sin(th)*B(1);
y=in(2)+r*cos(th)*A(2)+r*sin(th)*B(2);
z=in(3)+r*cos(th)*A(3)+r*sin(th)*B(3);
hold on
l=plot3(x,y,z)
Hope this helps
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!