How can we move an object from A to B and then return it to the same psition which is A ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
omar th
el 16 de Dic. de 2022
Comentada: omar th
el 18 de Dic. de 2022
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 comentarios
Respuesta aceptada
Karim
el 16 de Dic. de 2022
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
Más respuestas (0)
Ver también
Categorías
Más información sobre Filter Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!