function xyz_to_tp_test ( )

%*****************************************************************************80
%
%% xyz_to_tp_test() tests xyz_to_tp().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 July 2018
%
%  Author:
%
%    John Burkardt
%
  ntest = 6;

  ptest = [ ...
     1.0,  0.0,  0.0; ...
     0.0,  1.0,  0.0; ...
     0.0,  0.0,  1.0; ...
     1.0,  1.0,  1.0; ...
     5.0, -2.0, -1.0; ...
    -2.0, -2.0, -2.0 ]';

  fprintf ( 1, '\n' );
  fprintf ( 1, 'xyz_to_tp_test():\n' );
  fprintf ( 1, '  xyz_to_tp() converts XYZ to (Theta,Phi) coordinates.\n' );
  fprintf ( 1, '  tp_to_xyz() converts (Theta,Phi) to normalized XYZ coordinates.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '          P1          T       P            P2\n' );
  fprintf ( 1, '\n' );

  for i = 1 : ntest

    p1(1:3,1) = ptest(1:3,i);

    [ t, p ] = xyz_to_tp ( p1 );
    p2 = tp_to_xyz ( t, p );

    fprintf ( 1, '  %10f  %10f  %10f  %10f  %10f  %10f  %10f  %10f\n', ...
      p1(1:3,1), t, p, p2(1:3,1) );

  end

  return
end
