Mercurial > hg > octave-nkf
comparison scripts/quaternion/quaternion.m @ 3458:d25bc039237b
[project @ 2000-01-19 09:36:14 by jwe]
author | jwe |
---|---|
date | Wed, 19 Jan 2000 09:36:28 +0000 |
parents | e031284eea27 |
children | 22bd65326ec1 |
comparison
equal
deleted
inserted
replaced
3457:e031284eea27 | 3458:d25bc039237b |
---|---|
83 if (! is_vector (vv) || length (vv) != 3) | 83 if (! is_vector (vv) || length (vv) != 3) |
84 error ("vv must be a length three vector"); | 84 error ("vv must be a length three vector"); |
85 elseif (! is_scalar (theta)) | 85 elseif (! is_scalar (theta)) |
86 error ("theta must be a scalar"); | 86 error ("theta must be a scalar"); |
87 elseif (norm (vv) == 0) | 87 elseif (norm (vv) == 0) |
88 error ("quaternion: vv is zero."); | 88 error ("quaternion: vv is zero"); |
89 elseif (abs (norm (vv) - 1) > 1e-12) | 89 elseif (abs (norm (vv) - 1) > 1e-12) |
90 warning ("quaternion: ||vv|| != 1, normalizing") | 90 warning ("quaternion: ||vv|| != 1, normalizing") |
91 vv = vv / norm (vv); | 91 vv = vv / norm (vv); |
92 endif | 92 endif |
93 | 93 |
102 case(4) | 102 case(4) |
103 if (nargout != 1) | 103 if (nargout != 1) |
104 usage ("w = quaterion (a, b, c, d)"); | 104 usage ("w = quaterion (a, b, c, d)"); |
105 endif | 105 endif |
106 if (! (is_scalar (w) && is_scalar (x) && is_scalar (y) && is_scalar (z))) | 106 if (! (is_scalar (w) && is_scalar (x) && is_scalar (y) && is_scalar (z))) |
107 error ("input values must be scalars."); | 107 error ("input values must be scalars"); |
108 endif | 108 endif |
109 a = [w, x, y, z]; | 109 a = [w, x, y, z]; |
110 | 110 |
111 otherwise | 111 otherwise |
112 usage ("[a, b, c, d] = quaternion (w) or a = quaternion (w, x, y, z)"); | 112 usage ("[a, b, c, d] = quaternion (w) or a = quaternion (w, x, y, z)"); |