How to get X Y coordinates of a shape
Ältere Kommentare anzeigen
Hi I have a rectangle with rounded corners which I got through this:
"figure
rectangle('position',[0 -1 10 2],'Curvature',[1])
axis equal
grid minor "
But I need to get a number of x,y coordinates starting at the middle of the bottom line. it would also be useful to vary the number of coordinates I can get.
anyone have any ideas?
Many thanks in advanced!
2 Kommentare
Jan
am 24 Mai 2017
@Patrick: You do create a rectangle with the shown code. But actually you want something completely different. What exatlcy does "a number of x,y coordinates" mean? You tell us, where the coordinates should "start", and how are they defined? In which way do you want to vary the number?
What is the problem you want to solve?
Patrick
am 25 Mai 2017
Antworten (1)
Image Analyst
am 25 Mai 2017
0 Stimmen
rectangle() does not return that information. I've asked the Mathworks about that years ago. You'll have to find some other way to generate the x,y coordinates of the perimeter.
3 Kommentare
Cam S
am 19 Jul. 2019
any ideas?
Rik
am 19 Jul. 2019
You can use the fact that you have a mathematical description of the shape (4 lines, all 90 degree angles, combined with 4 quarter circles with equal radii) to generate the coordinates. A pure rectangle is easy with some calls to linspace (or just use only the corners),but once you want the rounding, things will get a bit more difficult.
Image Analyst
am 25 Jul. 2019
You could maybe just do your own rectangle as Rik described with your starting point at the top middle, then you can use conv to blur/smooth the points to round off the corners:
windowWidth = 15; % Whatever - some odd number
kernel = ones(1, windowWidth) / windowWidth;
xSmooth = conv(x, kernel, 'same');
ySmooth = conv(y, kernel, 'same');
If you repeat that a few times (6 or less), it should have rounded corners I believe (due to the Central Limit Theorem).
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!