Cutting a Circular Ring at particular points using angle-theta
4 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Les Beckham
on 25 Mar 2022
Edited: Les Beckham
on 25 Mar 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 Comments
More Answers (1)
Simon Chan
on 25 Mar 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 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!