How to get X Y coordinates of a shape

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
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
Patrick am 25 Mai 2017
Hi Jan,
I'm trying to get draw a plate (basically a rectangle with rounded corners). If I don't use the function I did before how could I do it? essentially the x-coordinates would be the length of the plate, and the y-coordinates would be the height. I'm trying to get a number of x,y coordinates (which I can vary, say 200 coordinates to start with) starting at the middle bottom of the plate and then going anti-clockwise around the plate.
So to recap, starting at the middle bottom of the plate i need to get around 200 x,y coordinates anti-clockwise back to the middle bottom of the plate, but these coordinates have to follow a specific geometry (for now the shape of the plate, I think later I might change the shape of the plate to an aerofoil shape)
I'm finding it really hard to explain, I hope this helps at least a little. Thanks for the speedy reply as well!
Regards, Patrick

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
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
Cam S am 19 Jul. 2019
any ideas?
Rik
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.
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).

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 24 Mai 2017

Kommentiert:

am 25 Jul. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by