42 #define real mbdyn_real_type
50 #define BOUNDS_CHECKING
52 #include <octave/oct.h>
54 DEFUN_DLD(rotation_matrix_to_rotation_vector,args,nargout,
"[phi] = rotation_matrix_to_rotation_vector(R)\n")
66 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 3 )
68 error(
"R must be a 3x3 matrix!");
72 Matrix
R_oct = args(0).matrix_value();
76 for (
int i = 0; i < 3; ++i )
77 for (
int j = 0; j < 3; ++j )
82 ColumnVector phi_oct(3);
84 for (
int i = 0; i < 3; ++i )
85 phi_oct(i) = phi(i+1);
87 retval.append(octave_value(phi_oct));
92 DEFUN_DLD(rotation_vector_to_rotation_matrix,args,nargout,
"[R] = rotation_vector_to_rotation_matrix(phi)\n")
96 int nargin = args.length();
104 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 1 )
106 error(
"Phi must be a 3x1 matrix!");
110 ColumnVector phi_oct = args(0).matrix_value().column(0);
114 for (
int i = 0; i < 3; ++i )
115 phi(i+1) = phi_oct(i);
121 for (
int i = 0; i < 3; ++i )
122 for (
int j = 0; j < 3; ++j )
125 retval.append(octave_value(R_oct));
130 DEFUN_DLD(rotation_matrix_to_euler123,args,nargout,
"[phi] = rotation_matrix_to_euler123(R)\n")
134 int nargin = args.length();
142 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 3 )
144 error(
"R must be a 3x3 matrix!");
148 Matrix R_oct = args(0).matrix_value();
152 for (
int i = 0; i < 3; ++i )
153 for (
int j = 0; j < 3; ++j )
158 ColumnVector phi_oct(3);
160 for (
int i = 0; i < 3; ++i )
161 phi_oct(i) = phi(i+1);
163 retval.append(octave_value(phi_oct));
168 DEFUN_DLD(euler123_to_rotation_matrix,args,nargout,
"[R] = euler123_to_rotation_matrix(phi)\n")
172 int nargin = args.length();
180 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 1 )
182 error(
"Phi must be a 3x1 matrix!");
186 ColumnVector phi_oct = args(0).matrix_value().column(0);
190 for (
int i = 0; i < 3; ++i )
191 phi(i+1) = phi_oct(i);
197 for (
int i = 0; i < 3; ++i )
198 for (
int j = 0; j < 3; ++j )
201 retval.append(octave_value(R_oct));
206 DEFUN_DLD(rotation_matrix_to_euler313,args,nargout,
"[phi] = rotation_matrix_to_euler313(R)\n")
210 int nargin = args.length();
218 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 3 )
220 error(
"R must be a 3x3 matrix!");
224 Matrix R_oct = args(0).matrix_value();
228 for (
int i = 0; i < 3; ++i )
229 for (
int j = 0; j < 3; ++j )
234 ColumnVector phi_oct(3);
236 for (
int i = 0; i < 3; ++i )
237 phi_oct(i) = phi(i+1);
239 retval.append(octave_value(phi_oct));
244 DEFUN_DLD(euler313_to_rotation_matrix,args,nargout,
"[R] = euler313_to_rotation_matrix(phi)\n")
248 int nargin = args.length();
256 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 1 )
258 error(
"Phi must be a 3x1 matrix!");
262 ColumnVector phi_oct = args(0).matrix_value().column(0);
266 for (
int i = 0; i < 3; ++i )
267 phi(i+1) = phi_oct(i);
273 for (
int i = 0; i < 3; ++i )
274 for (
int j = 0; j < 3; ++j )
277 retval.append(octave_value(R_oct));
282 DEFUN_DLD(rotation_matrix_to_euler321,args,nargout,
"[phi] = rotation_matrix_to_euler321(R)\n")
286 int nargin = args.length();
294 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 3 )
296 error(
"R must be a 3x3 matrix!");
300 Matrix R_oct = args(0).matrix_value();
304 for (
int i = 0; i < 3; ++i )
305 for (
int j = 0; j < 3; ++j )
310 ColumnVector phi_oct(3);
312 for (
int i = 0; i < 3; ++i )
313 phi_oct(i) = phi(i+1);
315 retval.append(octave_value(phi_oct));
320 DEFUN_DLD(euler321_to_rotation_matrix,args,nargout,
"[R] = euler321_to_rotation_matrix(phi)\n")
324 int nargin = args.length();
332 if ( !args(0).is_matrix_type() || args(0).rows() != 3 || args(0).columns() != 1 )
334 error(
"Phi must be a 3x1 matrix!");
338 ColumnVector phi_oct = args(0).matrix_value().column(0);
342 for (
int i = 0; i < 3; ++i )
343 phi(i+1) = phi_oct(i);
349 for (
int i = 0; i < 3; ++i )
350 for (
int j = 0; j < 3; ++j )
353 retval.append(octave_value(R_oct));
int error(const char *test, int value)
Mat3x3 EulerAngles313_2MatR(const Vec3 &v)
Vec3 VecRot(const Mat3x3 &Phi)
Mat3x3 EulerAngles123_2MatR(const Vec3 &v)
Vec3 MatR2EulerAngles313(const Mat3x3 &R)
Vec3 MatR2EulerAngles123(const Mat3x3 &R)
Mat3x3 Rot(const Vec3 &phi)
Mat3x3 EulerAngles321_2MatR(const Vec3 &v)
Vec3 MatR2EulerAngles321(const Mat3x3 &R)