I'm having difficulty plotting the Reuleaux triangle, i.e. the three arcs of circumference that connect the vertices of the equilateral triangle plotted in red are missing.
5 ビュー (過去 30 日間)
古いコメントを表示
function plotReuleauxTriangle(r, d)
% Plotta un triangolo di Reuleaux con i vertici specificati
% Definisci i vertici del triangolo
A = [-2.59808*r, 3*r/2 - d];
B = [2.59808*r, 3*r/2 - d];
C = [0, -d-3*r];
% Calcola i centri dei cerchi che compongono il triangolo
centerAB = [(A(1)+B(1))/2, (A(2)+B(2))/2];
centerBC = [(B(1)+C(1))/2, (B(2)+C(2))/2];
centerCA = [(C(1)+A(1))/2, (C(2)+A(2))/2];
% Calcola il raggio dei cerchi che compongono il triangolo
radius = norm(A-B)/2;
% Plotta i cerchi
t = linspace(0, 2*pi, 100);
xCircleAB = centerAB(1) + radius*cos(t);
yCircleAB = centerAB(2) + radius*sin(t);
xCircleBC = centerBC(1) + radius*cos(t);
yCircleBC = centerBC(2) + radius*sin(t);
xCircleCA = centerCA(1) + radius*cos(t);
yCircleCA = centerCA(2) + radius*sin(t);
hold on
plot(xCircleAB, yCircleAB, 'b')
plot(xCircleBC, yCircleBC, 'b')
plot(xCircleCA, yCircleCA, 'b')
% Plotta il triangolo equilatero
plot([A(1), B(1), C(1), A(1)], [A(2), B(2), C(2), A(2)], 'r')
axis equal
title('Triangolo equilatero')
xlabel('x')
ylabel('y')
end
I'm having difficulty plotting the Reuleaux triangle, i.e. the three arcs of circumference that connect the vertices of the equilateral triangle plotted in red are missing.
0 件のコメント
回答 (1 件)
Himanshu
2023 年 4 月 25 日
Hello Alessandro,
As per my understanding, you are trying to plot a Reuleaux triangle. To plot a Reuleaux triangle, you have to set the centres of the circles to be the vertices of the equilateral triangle, and the radius of each circle is equal to the side length of the triangle.
Refer to the below code:
function plotReuleauxTriangle(r, d)
% Define the vertices of the triangle
A = [-2.59808*r, 3*r/2 - d];
B = [2.59808*r, 3*r/2 - d];
C = [0, -d-3*r];
% Define the centers of the circles that compose the triangle
centerA = A;
centerB = B;
centerC = C;
% Calculate the radius of the circles that compose the triangle
radius = norm(A-B);
% Plot the circles
t = linspace(0, 2*pi, 100);
xCircleA = centerA(1) + radius*cos(t);
yCircleA = centerA(2) + radius*sin(t);
xCircleB = centerB(1) + radius*cos(t);
yCircleB = centerB(2) + radius*sin(t);
xCircleC = centerC(1) + radius*cos(t);
yCircleC = centerC(2) + radius*sin(t);
hold on
plot(xCircleA, yCircleA, 'b')
plot(xCircleB, yCircleB, 'b')
plot(xCircleC, yCircleC, 'b')
% Plot the equilateral triangle
plot([A(1), B(1), C(1), A(1)], [A(2), B(2), C(2), A(2)], 'r')
axis equal
title('Reuleaux Triangle')
xlabel('x')
ylabel('y')
end
I hope this helps.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!