-
Notifications
You must be signed in to change notification settings - Fork 24
/
mysph2cart.m
30 lines (28 loc) · 943 Bytes
/
mysph2cart.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function [x,y,z] = mysph2cart(az,inc,r)
% Spherical Coordinates to 3D Cartesian
%
% [x,y,z] = mysph2cart(az,inc,r)
%
% Inputs:
% az Azimuth angle in radians, measured counterclockwise
% from the positive x axis (otherwise referred to as phi)
% inc Inclination angle in radians, from positive z axis
% (otherwise referred to as theta)
% r Radius
%
% Outputs:
% x x-coordinate
% y y-coordinate
% z z-coordinate
%
% Notes:
% The MATLAB function cart2sph reverses phi and theta.
%
%**************************************************************************
% Author: E. A. P. Habets, M. R. P. Thomas and D. P. Jarrett
% Date: 24 August 2011
%**************************************************************************
z = r .* cos(inc);
rcosinc = r .* sin(inc);
x = rcosinc .* cos(az);
y = rcosinc .* sin(az);