Mercurial > hg > octave-lyh
diff scripts/quaternion/qtrans.m @ 3224:1e7532b9173b
[project @ 1998-12-04 22:08:23 by jwe]
author | jwe |
---|---|
date | Fri, 04 Dec 1998 22:08:23 +0000 |
parents | |
children | a892190f4977 |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/scripts/quaternion/qtrans.m @@ -0,0 +1,13 @@ +function v = qtrans(v,q) +# function v = qtrans(v,q) +# transform the unit quaternion v by the unit quaternion q; +# v = [w x y z], q = transformation quaternion +# returns v = q*v/q + +if(!is_vector(v) | length(v) != 4) + error(sprintf("qtrans: v(%d,%d) must be a quaternion",rows(v),columns(v))) +elseif(!is_vector(q) | length(q) != 4) + error(sprintf("qtrans: q(%d,%d) must be a quaternion",rows(q),columns(q))) +endif + +v = qmult(q,qmult(v,qinv(q)));