Cutting a Circular Ring at particular points using angle-theta
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Chris Dan
am 25 Mär. 2022
Bearbeitet: Les Beckham
am 25 Mär. 2022
Hello,
I am drawing a circular ring using the following code:
clear all; close all;
p = linspace(-1/2,1/2,100);
[X,Y] = meshgrid(p,p); % box mesh
R = p(size(p,2))/2;
r = R/1.5;
alpha = deg2rad(15);
alpha = linspace(-alpha,alpha,50);
[alpha_X,alpha_Y] = meshgrid(alpha,alpha);
theta = atan2(Y,X);
active = (X.^2 + Y.^2 <= R^2 & X.^2 + Y.^2 >= r^2);
figure()
plot(X(active),Y(active),'o','MarkerFaceColor','red');
hold on
This code is incomplete because I have to use alpha and theta to cut the ring at particular points.
The inequalities that I have are:
x^2+y^2<=R^2
x^2+y^2>=r^2
-alpha <=taninv(y/x)<=+alpha.
i have plotted the first two, I am confused as how to plot the third one, alpha one.
Does any on know how to plot the third inequality or how to use it to cut the ring at a particular angle.
the result which i get from above code is:
0 Kommentare
Akzeptierte Antwort
Les Beckham
am 25 Mär. 2022
Bearbeitet: Les Beckham
am 25 Mär. 2022
You were pretty close. See if you can adapt this to get what you want.
p = linspace(-1/2,1/2,100);
[X,Y] = meshgrid(p,p); % box mesh
R = p(size(p,2))/2;
r = R/1.5;
alpha = deg2rad(15);
theta = atan2(Y,X); % check size of theta; note it is already a mesh grid because X and Y are
% the whole circle (radius constraints only)
active = (X.^2 + Y.^2 <= R^2) & (X.^2 + Y.^2 >= r^2);
plot(X(active),Y(active),'o','MarkerFaceColor','red');
% the portion that satisfies the alpha constraint as well
active = (X.^2 + Y.^2 <= R^2) & (X.^2 + Y.^2 >= r^2) & (abs(theta) < alpha);
hold on
plot(X(active),Y(active),'o','MarkerFaceColor','blue');
0 Kommentare
Weitere Antworten (1)
Simon Chan
am 25 Mär. 2022
Try to add the follwoing lines:
alphaA = 15*pi/180; % Set the margin, 15 degree here
[thetaA,~] = cart2pol(X,Y);
angleA = abs(thetaA)<=alphaA;
active = (X.^2 + Y.^2 <= R^2 & X.^2 + Y.^2 >= r^2 & angleA);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!