So I essentially want to plot the change in trajectory as I perform a maneuver using the clohessy wiltshire equations to chase a target. I have a for loop for 10,000s and I would like to calculate each value of r(t) as I run through the loop and then plot it. Anyone know how this would be done? I can post code if you like.
close all n=0.00113; phi_rr = @(t) [4-3*cos(n*t) 0 0; 6*(sin(n*t)-n*t) 1 0; 0 0 cos(n*t)]; phi_rv = @(t) [1/n*sin(n*t) 2/n*(1-cos(n*t)) 0; 2/n*(cos(n*t)-1) 1/n*(4*sin(n*t)-3*n*t) 0; 0 0 1/n*sin(n*t)]; r_0 = [100;0;0]; v_0 = [-1;-.115;0]; T=0:10:2000; % plot red circle at origin plot3(0,0,0,'ro') hold on % start loop for t=T % display 50% progres if t==T(floor(end/2)) disp('50 % done'); end r=phi_rr(t)*r_0 + phi_rv(t)*v_0; plot3(r(1),r(2),r(3),'k.'); end rotate3d xlabel('x'), ylabel('y'), zlabel('z') axis equal grid on hold off
According to wikipedia and this, x-axis points radially from center of gravity to the target, y-axis points into the targets direction of movement, and the z-axis is just perpendicular to the previous (right-handed system). So, with the initial values provided as an example above, the trajectory looks like this:
The view is relative to the target (red circle), i.e. how the target sees the chaser move.
That means the chaser starts at 100 meters radially outwards of the target's position and with a velocity of -1 m/s radially inwards and -11.5 cm/s tangentially backwards relative to the target.
The chaser hits the target with non-zero velocity. So to make it more realistic, you'd have to do a multi-step simulation with subsequently decreasing velocity of the chaser.