Functions | |
endif | if ((ismatrix(theta)&&ismatrix(phi)&&ismatrix(r))&&(size_equal(theta, phi)||isscalar(theta)||isscalar(phi))&&(size_equal(theta, r)||isscalar(theta)||isscalar(r))&&(size_equal(phi, r)||isscalar(phi)||isscalar(r))) x |
else | error ("sph2cart: arguments must be matrices of same size, or scalar") |
!assert (x, r) | |
!assert (y,[0, 0, 0]) | |
!assert (z,[0, 0, 0]) | |
!assert (x,[1, 0,-1], eps) | |
!assert (y,[0, 1, 0], eps) | |
!assert (z,[0, 0, 0], eps) | |
Variables | |
function [x, y, z] | |
y = r .* cos (phi) .* sin (theta) | |
z = r .* sin (phi) | |
endif endfunction!test | !t = [0, 0, 0] |
!p = [0, 0, 0] | |
!r = [0, 1, 2] |
!assert | ( | z | , | |
eps | ||||
) |
!assert | ( | y | , | |
eps | ||||
) |
!assert | ( | x | , | |
eps | ||||
) |
!assert | ( | z | ) |
!assert | ( | y | ) |
!assert | ( | x | , | |
r | ||||
) |
endif if | ( | (ismatrix(theta)&&ismatrix(phi)&&ismatrix(r))&&(size_equal(theta, phi)||isscalar(theta)||isscalar(phi))&&(size_equal(theta, r)||isscalar(theta)||isscalar(r))&&(size_equal(phi, r)||isscalar(phi)||isscalar(r)) | ) |
!p = [0, 0, 0] |
!r = [0, 1, 2] |
!test !t = [0, 0, 0] |
z = r .* sin (phi) |