%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% yu.m
% Simple y-u tracing for N surfaces
%
% Nov 2021
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear; clc;

% Power of the surfaces P = 1/f.
% For OBJ and IMA planes P = 0.
p = [0 1/50 1/25 -1/200 0];

% Thickness (distance) between surfaces
t = [90 110 280 120];
N = length(t);

% Initial values (position, height and angle)
z(1) = 0.0;
y(1) = 5.0;
u(1) = 0.1;

% y-u trace
for k = 1:N
   z(k+1) = z(k) + t(k);
   y(k+1) = y(k) + u(k)*t(k);
   u(k+1) = u(k) - y(k+1)*p(k+1);
end

% print the results
result = [z' y' u']
