From: <jpi...@us...> - 2011-11-14 22:35:52
|
Revision: 9098 http://octave.svn.sourceforge.net/octave/?rev=9098&view=rev Author: jpicarbajal Date: 2011-11-14 22:35:45 +0000 (Mon, 14 Nov 2011) Log Message: ----------- quaternions_oo . Power vectorized to matrices of quaternions. Modified Paths: -------------- trunk/octave-forge/extra/quaternion_oo/devel/RV9_Quaternions.txt trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/power.m Modified: trunk/octave-forge/extra/quaternion_oo/devel/RV9_Quaternions.txt =================================================================== --- trunk/octave-forge/extra/quaternion_oo/devel/RV9_Quaternions.txt 2011-11-14 19:13:11 UTC (rev 9097) +++ trunk/octave-forge/extra/quaternion_oo/devel/RV9_Quaternions.txt 2011-11-14 22:35:45 UTC (rev 9098) @@ -106,9 +106,9 @@ DONE Q = Quaternion(TH, V) is a unit quaternion corresponding to rotation of TH about the vector V. - Q = Quaternion(R) is a unit quaternion corresponding to the orthonormal rotation matrix R. +DONE Q = Quaternion(R) is a unit quaternion corresponding to the orthonormal rotation matrix R. - Q = Quaternion(T) is a unit quaternion equivalent to the rotational +DONE Q = Quaternion(T) is a unit quaternion equivalent to the rotational = methods = DONE [c] inv return inverse of quaterion Modified: trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/power.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/power.m 2011-11-14 19:13:11 UTC (rev 9097) +++ trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/power.m 2011-11-14 22:35:45 UTC (rev 9098) @@ -33,8 +33,9 @@ a.x = -a.x ./ norm2; a.y = -a.y ./ norm2; a.z = -a.z ./ norm2; - else + elseif isvector (a.w) + na = abs (a); th = acos (a.w ./ na); n = bsxfun (@rdivide, [a.x a.y a.z] ,sqrt ((a.x).^2 + (a.y).^2 + (a.z).^2)); @@ -47,6 +48,23 @@ a.y = n(:,2) .* nab .* snt; a.z = n(:,3) .* nab .* snt; + else + + na = abs (a); + th = acos (a.w ./ na); + nv = sqrt ((a.x).^2 + (a.y).^2 + (a.z).^2); + n.x = a.x ./ nv; + n.y = a.y ./ nv; + n.z = a.z ./ nv; + + nab = na.^b; + a.w = nab .* cos (b.*th); + + snt = sin (b.*th); + a.x = n.x .* nab .* snt; + a.y = n.y .* nab .* snt; + a.z = n.z .* nab .* snt; + endif endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |