2D Animated Orientation Vector of Satellite in Orbit

Hello,
I have written a code that calculates the 2-dimensional (x,y) position of a satellite in orbit as well as the angle theta that gives the 2D orientation of that satellite with respect to my x-y axis. I am using the comet function to animate the position of my satellite over time and I want to add it's orientation to the animation. Basically right now I have a point that moves in a circle with time in the animation and I would instead like a vector who's origin moves in a circle but who's direction varries with my angle theta.
Any thoughts on how I can create this animation?

Réponses (1)

Here is an example
clc,clear
t = linspace(0,2*pi,30);
[x,y] = pol2cart(t,2);
dx = diff(x);
dy = diff(y);
plot(x,y)
hold on
h1 = quiver(0,0,x(1),y(1));
h2 = quiver(x(1),y(1),dx(1),dy(1));
hold off
for i = 2:length(dx)
set(h1,'udata',x(i),'vdata',y(i))
set(h2,'xdata',x(i),'ydata',y(i),...
'udata',dx(i),'vdata',dy(i))
pause(0.1)
end

4 commentaires

Thanks, but how would I get the arrow's origin to rotate around on the circle and the arrow to point in the direction my object is facing? I currenly have an array of positions (x and y) as a function of time, I also have my time array. Finally I have a unit vector (x and y) that represents where the object is facing. I would like to create an animation where the origin of the arrow is located at my position as a function of time and the arrow is pointing in the direction of my orientation unit vector.
Sorry, I didn't see that there was a smaller arrow in your example doing what I was asking for. I think I have almost got it figured out. I'm just trying to understand what udata, vdata, xdata, and ydata are.
Austin Sharpe
Austin Sharpe le 4 Août 2021
Modifié(e) : Austin Sharpe le 4 Août 2021
@Devin Dalton xdata and ydata updates the x and y position of the vector defined in the quiver plot. udata and vdata updates the u-component and v-components of the vector, corresponding to the x and y directions, respectively. A cleaner way to do the same thing would be:
for i = 2:length(dx)
h1.UData = dx(i);
h1.VData = dy(i);
h2.XData = x(i);
h2.YData = y(i);
pause(0.1)
end
darova
darova le 5 Août 2021

Connectez-vous pour commenter.

Catégories

En savoir plus sur Vector Fields dans Centre d'aide et File Exchange

Commenté :

le 5 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by