How can I rotate a curved rectangle?

I have created a curved rectangle and now I want to rotate it. I know I can not rotate using rectangle commande. I also tried to plot the rotated rectangle using "fill" but then I can not add curvature.
So, the question is, How can I plot a rotated curved rectangle?

2 件のコメント

Adam Danz
Adam Danz 2021 年 1 月 10 日
編集済み: Adam Danz 2021 年 3 月 22 日
rectangle2() from the file exchange can rotate a curved rectangle.
rectangle2([x,y,w,h],'Curvature',[a,b],'Rotation',deg);
Examples:
Antje Nuthmann
Antje Nuthmann 2021 年 3 月 20 日
rectangle2 works well, thanks!

サインインしてコメントする。

回答 (2 件)

Friedrich
Friedrich 2013 年 4 月 10 日

0 投票

HI,
so you have a set of points (x,y) describing a curved rectangle. I guess the keyword here is rotation matrix:
Create the Matrix accoringly and multiple it with your (x,y) values to get the rotated rectangle.

6 件のコメント

Laleh
Laleh 2013 年 4 月 10 日
But the problem is the command "rectangle" does not support rotation. There is no way, I guess, to rotate a rectangle using the commande "rectangle".
Friedrich
Friedrich 2013 年 4 月 10 日
Yes in that case no chance. You would need do draw that rectangle by yourself to get x,y points and then rotate it by your own or using the rotate function.
Laleh
Laleh 2013 年 4 月 10 日
What do you mean by rotate function? Let's say I have my rotated (x,y) values. If I give these values to function "fill" I will have a nice rotated rectangle. Having these values what is the code to plot the curved rectangle?
Friedrich
Friedrich 2013 年 4 月 10 日
The rotate function can rotate graphic objects:
But not a rectangle object :(
Laleh
Laleh 2013 年 4 月 10 日
Yes that is my point, so what should I do now? :(
Friedrich
Friedrich 2013 年 4 月 11 日
You need to create your own version of the rectangle function which calculates the curved rectangle from scratch. Afterwards you can plot it an rotate it.

サインインしてコメントする。

Rafal Samborski
Rafal Samborski 2013 年 4 月 10 日
編集済み: Rafal Samborski 2013 年 4 月 10 日

0 投票

If it's ony about plotting try to call this after your plot function:
alpha = 30; set(gca, 'View', [alpha 90]);

1 件のコメント

Laleh
Laleh 2013 年 4 月 10 日
After the "rectangle" command when I add your code, it rotates the axis of the plot, and does not show anything inside, just white plot!!!

サインインしてコメントする。

カテゴリ

質問済み:

2013 年 4 月 10 日

編集済み:

2021 年 3 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by