1function [J,J1,J2] = eulerang(phi,theta,psi)
 2% [J,J1,J2] = EULERANG(phi,theta,psi) computes the Euler angle
 3% transformation matrices
 4%
 5% Author:   Thor I. Fossen
 6% Date:     14th June 2001
 7% Revisions: 
 8
 9cphi = cos(phi);
10sphi = sin(phi);
11cth  = cos(theta);
12sth  = sin(theta);
13 
14J1 = Rzyx(phi,theta,psi);
15 
16if cth==0, error('J2 is singular for theta = +-90 degrees'); end
17 
18J2 = [...
19      1  sphi*sth/cth  cphi*sth/cth;
20      0  cphi          -sphi;
21      0  sphi/cth      cphi/cth ];
22 
23J = [ J1  zeros(3,3);
24      zeros(3,3) J2 ];