# Model Motion of Circling Airplane

Start with an airplane moving along a circular track with a radius of 10 km at a horizontal speed of 100 m/s and descending at a rate of 1 m/sec. To create circular motion, specify a radially-inward acceleration and constrain the acceleration to lie in the horizontal plane. The acceleration of a body moving in a circle is $\frac{{\mathit{v}}^{2}}{\mathit{r}}$. The rate of descent is constant. Set the initial orientation axes matrix of the platform to the identity matrix.

### Set up the initial conditions

```alt = 10000; radcirc = 10000; % 10 km phi = 60; initPos = [cosd(phi)*radcirc;sind(phi)*radcirc;alt]; vs = 100.0; vx = vs*sind(phi); vy = -vs*cosd(phi); vz = -1; initVel = [vx,vy,vz]'; airplane = phased.Platform('MotionModel','Acceleration', ... 'AccelerationSource','Input port','InitialPosition',initPos, ... 'InitialVelocity',initVel,'OrientationAxesOutputPort',true, ... 'InitialOrientationAxes',eye(3)); accelmag = vs^2/radcirc; initPos1 = [cosd(phi)*radcirc;sind(phi)*radcirc;0]; unitvec = initPos1/radcirc; accel = -accelmag*unitvec;```

### Compute the trajectory

Compute the trajectory for 20000 integration steps at T = 0.1 s intervals

```N = 20000; tstep = .10; posmat = zeros(3,N); for n = 1:N [pos,vel,oax] = airplane(tstep,accel); velcirc2 = vel(1)^2 + vel(2)^2; vmag = sqrt(velcirc2); pos1 = [pos(1),pos(2),0]'; radcirc = sqrt(pos1'*pos1); unitvec = pos1/radcirc; accelmag = velcirc2/radcirc; accel = -accelmag*unitvec; posmat(:,n) = pos; end```

Display the final orientation of the local coordinate system.

`disp(oax)`
``` 0.1271 0.9919 0.0001 -0.9919 0.1271 0.0003 0.0003 -0.0001 1.0000 ```

### Plot the trajectory

```plot3(posmat(1,:)/1000,posmat(2,:)/1000,posmat(3,:)/1000,'b.') xlabel('X (km)') ylabel('Y (km)') zlabel('Z (km)') axis equal grid```