How to change the ratio of sectors for a circle with 8 equal sectors

조회 수: 49 (최근 30일)
Nguyen
Nguyen 2025년 10월 10일 20:17
댓글: DGM 2025년 10월 11일 21:16
I have a circle with 8 equal sectors and radius one(Below is the code I used)
Now, I want to be able to move the circle around whilst keeping the partition lines in place(like in the image below), How can I do this but also be able to calculate the area of each sector for the new circle ?
  댓글 수: 5
Matt J
Matt J 2025년 10월 10일 23:02
편집: Matt J 2025년 10월 10일 23:40
I want to be able to move the circle around whilst keeping the partition lines in place(like in the image below), How can I do this but also be able to calculate the area of each sector for the new circle ?
Why would the movement of the circle change the area of the sectors?
Do you mean you the center of the radiating pattern is moving while the circumference is not? If so, those aren't really "sectors" anymore, strictly speaking.
Walter Roberson
Walter Roberson 2025년 10월 10일 23:22
@Matt J The center point that is acting as the intersection, is moving. It is obvious that the areas of the 8 sectors are going to change.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2025년 10월 10일 23:07
편집: Matt J 2025년 10월 11일 0:00
One possibility:
dTheta=360/8; %sector angle
t=linspace(0,dTheta)';
sector=polyshape([0,0;cosd(t),sind(t)]);
circle=arrayfun(@(z)rotate(sector,z),(0:7)*dTheta);
newcircle=newCenter(circle, [+0.5,0]);
sectorAreas=area(newcircle)
sectorAreas = 1×8
0.8012 0.4625 0.1979 0.1092 0.1092 0.1979 0.4625 0.8012
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
plot(newcircle); axis equal
function circle=newCenter(circle, t)
R=sqrt(sum(area(circle))/pi); %radius
mag=1+norm(t)/R;
Circle=scale(circle,mag,[0,0]);
circle=intersect( translate(union(circle),t) , Circle);
end

추가 답변 (1개)

DGM
DGM 2025년 10월 11일 11:58
편집: DGM 2025년 10월 11일 12:19
Alternative interpretation, also using polyshape():
This still subdivides the outer circle into equal arc lengths. I'm not really sure if that is intended.
The circle and line intersection positions can be defined independently, so you can choose how you want to configure it.
nsectors = 8; % number of sectors
lineint = [0 0.2]; % position of line intersection
center = [0.5 -0.2]; % position of circle center
radius = 1; % radius of outer circle
np = 100; % points per arc
th = linspace(0,2*pi,nsectors+1); % breakpoint angles
P = repmat(polyshape(),[nsectors 1]);
for k = 1:nsectors
arcth = linspace(th(k),th(k+1),np).';
V = [lineint; [cos(arcth) sin(arcth)] + center];
P(k) = polyshape(V);
end
% i'm using different colors since this is slightly longer than lines()
% this will avoid repeated colors and clearly indicates the sequence order
colororder(parula(nsectors))
plot(P); axis equal; grid on
area(P)
ans = 8×1
0.5109 0.3245 0.1781 0.1573 0.2745 0.4609 0.6073 0.6281
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  댓글 수: 2
Torsten
Torsten 2025년 10월 11일 17:42
Cited from the OP:
Now, I want to be able to move the circle around whilst keeping the partition lines in place(like in the image below),
So I think @Matt J 's interpretation is correct.
DGM
DGM 2025년 10월 11일 21:16
I saw that, but given the manner in which the original code constructed the plot and the crudeness of the drawing, I considered it ambiguous enough that it would be worth throwing down an example anyway. It's my time to waste, after all.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by