rotating an image while moving

3 ビュー (過去 30 日間)
Kevin
Kevin 2014 年 2 月 19 日
コメント済み: Kevin 2014 年 2 月 19 日
In my code I am attempting to move a box along a path, when it is moving it needs to be rotating in a circle. However I am unsure of where to start. I have the box moving along the required path using the following code.
Xcoordinate = [0,0,5,5];
Ycoordinate = [0,5,5,0];
figure
hold on;
for t = [0:0.02:5.85];
x = 50*cosd(35)*t;
y = 50*t*sind(35)-9.81*(t^2)/2;
theta = 5*pi/180;
rotationfactorx = [cos(theta), -sin(theta)];
rotationfactory = [sin(theta), cos(theta)];
sqr = fill(Xcoordinate+x,Ycoordinate+y,'y');
axis([-20 250 -20 250]);
pause(.02);
delete(sqr);
end

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 2 月 19 日
Put the box in a hgtramsform group. Use makehgtransform() to calculate the new rotation matrix and then set() it in the hgtransform group to get the effect of the rotation and movement.
  1 件のコメント
Kevin
Kevin 2014 年 2 月 19 日
I am unfamiliar with this command, could you explain in more detail how I would apply it to my code?

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

カテゴリ

Help Center および File ExchangeGraphics Performance についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by