Как рассчитать площадь сегментов в круге, образованном случайными 3 линиями, соединяющими 3 набора из 2 точек по окружности в Matlab - PullRequest
0 голосов
/ 20 октября 2019

Мне нужно рассчитать площадь сегментов в круге, образованном 3 случайными линиями внутри круга (каждая линия касается окружности круга).

Ниже приведен код, который я использовал для построения круга и случайных 3 линий. Необходимо рассчитать площадь каждого сгенерированного сегмента.

clear all
close all
clc

x = 6;
y = 7;
r = 3;

th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
hold on
axis equal


p1 = randi([1 length(xunit)]);
p2 = randi([1 length(xunit)]);

p3 = randi([1 length(xunit)]);
p4 = randi([1 length(xunit)]);

p5 = randi([1 length(xunit)]);
p6 = randi([1 length(xunit)]);



%% Get the intersection points


[xi_1,yi_1] = polyxpoly([xunit(p1) xunit(p2)] , [yunit(p1) yunit(p2)] , [xunit(p3) xunit(p4)] , [yunit(p3) yunit(p4)]);
[xi_2,yi_2] = polyxpoly([xunit(p1) xunit(p2)] , [yunit(p1) yunit(p2)] , [xunit(p5) xunit(p6)] , [yunit(p5) yunit(p6)]);
[xi_3,yi_3] = polyxpoly([xunit(p3) xunit(p4)] , [yunit(p3) yunit(p4)] , [xunit(p5) xunit(p6)] , [yunit(p5) yunit(p6)]);



%% Plot the cuts and the intersections

% Plot the cuts

plot([xunit(p1) xunit(p2)],[yunit(p1) yunit(p2)]);
hold on
plot([xunit(p3) xunit(p4)],[yunit(p3) yunit(p4)]);
hold on
plot([xunit(p5) xunit(p6)],[yunit(p5) yunit(p6)]);
hold on

% Plot intersection points

plot(xi_1,yi_1,'ro');
hold on
plot(xi_2,yi_2,'ro');
hold on
plot(xi_3,yi_3,'ro');
hold off

Любая помощь высоко ценится.

...