Getting current position (x,y) of a 2D object created with a patch

10 ビュー (過去 30 日間)
kablai tokhi
kablai tokhi 2018 年 5 月 11 日
コメント済み: kablai tokhi 2018 年 5 月 14 日
x = [-9 , 3, 1, 9, 1, 3, -9 ];
y = [-3,-3,-9/2, 0, 9/2, 3, 3];
g = hgtransform;
patch('XData',x,'YData',y,'FaceColor','yellow','Parent',g)
The patch moves consistently through the plot, at 2 points it stops to correct its angle. Is there anyway to get a hold of its current x&y positions at that point for further use?

回答 (1 件)

sloppydisk
sloppydisk 2018 年 5 月 11 日
p = patch('XData',x,'YData',y,'FaceColor','yellow','Parent',g);
p.Vertices
This should do it.
  2 件のコメント
kablai tokhi
kablai tokhi 2018 年 5 月 14 日
Hey Jasper, i tried it, the thing about vertices is that it gives me the limitations of the object itself and not its location in the plot.
kablai tokhi
kablai tokhi 2018 年 5 月 14 日
i found the answer :) so there is no real function, but the object 'g' is a matrix, and by calling g.Matrix i found out that it had the x and y coordinates in it. So now i just get a hold of those specifically and use them for future use.
My problem now is that the 2nd rotation using makehgtform doesnt really work. It sort of moves object instead of rotating.

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

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by