Problems about "rotate" function
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi!!
I'm experiencing the following problem.
k=2;
for i=2:length(t_inf_sgross)
b(k)=subtract(D(k-1),C2(k-1));
D(k)=rotate(b(k),Delta_phi(i));
k=k+1;
end
ruotato=rotate(b(end),-35)
plot(ruotato)
I'm creating a vector called "b" containing a series of polyshapes that results from the subtraction/rotation of geometries contained in "C" vector.
The problem is that when i call the final geometry resulted in "b" vector, then called "ruotato" and i rotate it of a certain angle (here -35°), Matlab seems to rotate only the perimeter but not the area of this geometry, giving the result i post below:

Why this happen?
Thank you!
採用された回答
Presumably because b(end) is the perimeter, i.e., it is a polyshape containing almost no internal area.
12 件のコメント
Francesco
2020 年 11 月 15 日
I don’t understand. When i subtract two polyshapes and Matlab creates another polyshape, how can it be “empty” ? Is there a way to solve this problem?
It isn't "empty". You've subtracted so much of the interior that all that is left is a thin border. This is all we can deduce from what you've posted. If you could attach additional code and/or a .mat file of input variables so that we can run the loop ourselves, we could analyze the results more directly.
Francesco
2020 年 11 月 15 日
The code is very long. I try to be as exhaustive as possibile.
- I create a matrix in which every column and the next one represent the X and Y coordinates of the points of the perimeter of a tool composed by 23 teeth at diferent instant of time. So, column 1 and 2 are X & Y at instant n°1, column 3 and 4 are X & Y at instant n°2, and so on. Now i need to make polyshapes of these teeth, because the tool has to be subtracted from the raw material as the time passes.
- By a for loop i create a polyshape of every tooth of the tool. The result is a matrix composed by 23 x (n° instant of time) polyshapes. Now i have the tool composed by 23 teeth at various working times.
- By another for loop and "unite" function (usually very time expensive due to high number of instants) i unite teeth to have 1x(n°instant of working time) vector called C2, containing polyshapes that represent the tool positions. Now i am ready to subtract from raw material.
By a for loop i subtract C2 position of the tool to the D(k) raw material. Then, i need to rotate D(k) before doing the next subtraction because the raw rotates in reality together with the tool. The raw is a ring, i subtract only a little part of it represented by the 23 teeth of the tool.
The result is correct, but the D rotation gives the problem i posted above.
k=2;
for i=2:length(t_inf_sgross)
b(k)=subtract(D(k-1),C2(k-1));
D(k)=rotate(b(k),Delta_phi(i));
k=k+1;
end
ruotato=rotate(b(end),-35)
plot(ruotato)
Matt J
2020 年 11 月 15 日
Well, attach a .mat file containing the resulting polyshape array b, then. That way, we can try just the rotation part ourselves.
Francesco
2020 年 11 月 15 日
Here you are.
I attached the last element of "b" because the entire vector was too heavy :D
The next problem will be how to lighten the code, it works but it lasts like the entire working process :D
Well, this is what I did with the file,
S=load('b_file');
b=S.test;
plot(b)
axis equal
hold on
ruotato=rotate(b(end),-35);
plot(ruotato)
hold off
and what I got looks fine. I recommend you redo the plot in a fresh figure window and see if that doesn't fix things. Maybe a previous hold command messed things up.

Francesco
2020 年 11 月 15 日
It keeps going wrong to me. Try to rotate only “b(end)”, maybe if you superpose the rotated and not rotated you don’t see the error.
Did you try executing my code? Clear all figures and your entire workspace and just try to repeat what I have done using b_file.mat only. Also, what Matlab version are you using?
It seems to work if i plot it out of the main code, as you said! If i try to make the same in the main code, it gives the problem.
How is it possible?
Matlab R2018
How is it possible?
No way to know since you're not showing us your complete plot commands. There are several objects in your posted plot, but you show the command that was issued for only one of them. I recommend, in any case, that you do not modify you plots at many different stages throughout your long code. Just plot everything in one place at the very end of the code.
I can’t post the entire plot because it’s a 785 MB file. I can’t plot only the last position because the final geometry is the result of multiple positions of the tool as function of time. As you said I’ll load the result in a separate window and there i’ll make my operations. The next topic will be how to lighten the code. It lasts 1 hour.. i will post it in another topic :)
Matt J
2020 年 11 月 16 日
The next topic will be how to lighten the code. It lasts 1 hour.. i will post it in another topic :)
OK, but if we are done with this topic, please Accept-click the answer.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Elementary Polygons についてさらに検索
参考
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
