How can we move an object from A to B and then return it to the same psition which is A ?
2 ビュー (過去 30 日間)
古いコメントを表示
if we move the object below from position A (-50,50) to position B. how can we make return to A position again ??
thanks in advance
oldPosition = [-50 ,50];
agleoption = [-14.3239 -7.1620 -4.7746 1.4324 1.5915 1.7905 7.1620 14.3239];
abgle = agleoption(length(agleoption),1);
DXrotated = [cos(angle(:)) .* v1 ,sin(angle(:)) .* v1]; % displacement ,v1 is velocity of an object, v1=2 m/sec
newPosition = oldPosition + DXrotated;
0 件のコメント
採用された回答
Karim
2022 年 12 月 16 日
I tried to made a commented example, hope it helps
% initial poistion at x = -50 m and y = 50 m
oldPosition = [-50; 50];
% set up the velocity vector -> x = 2 m/s and y = 0 m/s
Velocity = [2; 0];
% a list with angluar options --> in radians
angleoption = [-14.3239 -7.1620 -4.7746 1.4324 1.5915 1.7905 7.1620 14.3239];
% pick an angle from the options
MyAngle = angleoption(end);
% set up the rotation matrix as a function
MyRot =@(x) [cos(x) -sin(x); sin(x) cos(x)];
% obtain the rotated velocity vector
MyDir = MyRot(MyAngle) * Velocity
% new position equals the old position plus the displacement obtained after a single step
newPosition = oldPosition + MyDir
% to move backwards, change the sign of the sign of the rotated velocity vector
startPosition = newPosition - MyDir
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Filter Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!