function [Corners,Diag_1, Diag_2] = coilcorner(x,y,z)
%coilcorner: Takes structure array location and finds the corners assuming
%the object is a cuboid. Outputs are those coordinates organised into the
%two diagonal planes.

Corners = [ min(x) , min(y) , min(z);...
    max(x) , min(y) , min(z);...
    min(x) , max(y) , min(z);...
    max(x) , max(y) , min(z);...
    min(x) , min(y) , max(z);...
    max(x) , min(y) , max(z);...
    min(x) , max(y) , max(z);...
    max(x) , max(y) , max(z)];


Diag_1 = [Corners(1,:);Corners(4,:);Corners(8,:);Corners(5,:)];
Diag_2 = [Corners(3,:);Corners(2,:);Corners(6,:);Corners(7,:)];

% %Visual Check:
% plot3(x,y,z,'kx'); hold on;
% plot3(Corners(:,1),Corners(:,2),Corners(:,3),'ro');

end

