2
$\begingroup$

I have a csv file. Inside the csv file, there are few rows of 4 quartenion values. I would like to animate the quarternion nb in http://demonstrations.wolfram.com/FromQuaternionTo3DRotation/

I believe I should begin with this line

data = Import["C:\\Users\\User\\Desktop\\a.csv", "List"]

But what should I do to animate the quarternion? Below is the quarternion code.

Manipulate[
 Module[{mod, theta, axemin, axemax, rayon, u, v, w},
  mod = Sqrt[a^2 + ax^2 + ay^2 + az^2];
  theta = ArcCos[a/mod];
  axemin = -2.5;
  axemax = 2.5;
  rayon = 2;
  u = {ax/Sin[theta]/mod, ay/Sin[theta]/mod, az/Sin[theta]/mod}; 
  v = Cross[u, {Cos[3 Pi/4], Sin[3 Pi/4], 0}]/
    Norm[Cross[u, {Cos[3 Pi/4], Sin[3 Pi/4], 0}]];
  w = Cross[u, {Cos[3 Pi/4 + theta], Sin[3 Pi/4 + theta], 0}]/
    Norm[Cross[u, {Cos[3 Pi/4 + theta], Sin[3 Pi/4 + theta], 0}]];
  Show[
   Graphics3D[{ Thickness[0.003],
     Line[{{axemin, 0, 0}, {axemax, 0, 0}}],
     Line[{{0, axemin, 0}, {0, axemax, 0}}],
     Line[{{0, 0, axemin}, {0, 0, axemax}}],
     Arrowheads[0.03],
     Arrow[{{0, 0, 0}, {axemax, 0, 0}}],
     Arrow[{{0, 0, 0}, {0, axemax, 0}}],
     Arrow[{{0, 0, 0}, {0, 0, axemax}}],
     Text[Style["x", Italic, 12], {0.92 axemax, 0, 0.2}],
     Text[Style["y", Italic, 12], {0, 0.92 axemax, 0.2}],
     Text[Style["z", Italic, 12], {0.2, 0, 0.92 axemax}],
     Opacity[0.5], Cylinder[{+0 u, 0.01 u}, rayon], Blue, 
     Thickness[0.007],
     Opacity[0.9], Line[{1.5*axemin*u, 1.5*axemax*u}], 
     Thickness[0.003],
     Red, Line[{0.01*u, 0.01*u + rayon*v}],
     Line[{0.01*u, 0.01*u + rayon*w}],
     Thickness[0.005],
     Arrow[{{0, 0, 0}, 0.01*u + 0.7*rayon*v}],
     Arrow[{{0, 0, 0}, 0.01*u + 0.7*rayon*w}],
     Text[
      Style["\!\(\*OverscriptBox[\(v\), \(\[RightVector]\)]\)", 
       12], {0.01*u + 0.7*rayon*v + 0.2*u}], 
     Text[Style[Row[{Style["r", Italic], "(", (
\!\(\*OverscriptBox[\(Style["\<v\>", Plain, 
            Bold]\), \(\[RightVector]\)]\)), ")"}], 
       12], {0.01*u + 0.7*rayon*w + 0.3*u}]}, 
    PlotRange -> {{axemin, axemax}, {axemin, axemax}, {axemin, 
       axemax}}, ImageSize -> 1.2 {350, 350}], 
   ParametricPlot3D[
    0.01*u + 
     0.7*rayon*
      Cross[u, {Cos[3 Pi/4 + t], Sin[3 Pi/4 + t], 0}]/
       Norm[Cross[u, {Cos[3 Pi/4 + t], Sin[3 Pi/4 + t], 0}]], {t, 0, 
     theta}, PlotStyle -> Red]]],
 Delimiter,
 Text@Style[
   Row[{"quaternion: ", "\[ScriptCapitalA]", " = ", Style["a", Italic],
      " + ", Style["\!\(\*SubscriptBox[\(a\), \(x\)]\)", Italic], 
     " ", Style["i", Bold],
     " + ", Style["\!\(\*SubscriptBox[\(a\), \(y\)]\)", Italic], " ", 
     Style["j", Bold],
     " + ", Style["\!\(\*SubscriptBox[\(a\), \(z\)]\)", Italic], " ", 
     Style["k", Bold]}], 12], {{a, 0, 
   Text@Style["a", Italic, 12]}, -2, 2, 0.01, Appearance -> "Labeled",
   ImageSize -> Small}, {{ax, 0.5, 
   Text@Style["\!\(\*SubscriptBox[\(a\), \(x\)]\)", Italic, 12]}, -2, 
  2, 0.01, Appearance -> "Labeled", 
  ImageSize -> Small}, {{ay, 0.5, 
   Text@Style["\!\(\*SubscriptBox[\(a\), \(y\)]\)", Italic, 12]}, -2, 
  2, 0.01, Appearance -> "Labeled", 
  ImageSize -> Small}, {{az, 0.5, 
   Text@Style["\!\(\*SubscriptBox[\(a\), \(z\)]\)", Italic, 12]}, -2, 
  2, 0.01, Appearance -> "Labeled", ImageSize -> Small}, 
 ControlPlacement -> Left]
$\endgroup$

closed as off-topic by Kuba, Feyre, Wjx, happy fish, m_goldberg Sep 18 '16 at 12:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Kuba, Feyre, Wjx, happy fish, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Don't forget to format your code. $\endgroup$ – Edmund Nov 7 '15 at 19:28
  • 1
    $\begingroup$ If only we had that *.csv file... $\endgroup$ – J. M. will be back soon Nov 8 '15 at 9:10
  • $\begingroup$ This is the content. Sorry for not uploading as I dunno how to do so. 0,-0.019878445,0.2981767,0.9543037 0.036677353,0.02482699,0.6954033,0.71725357 0,0,-0.99989706,-0.014346213 $\endgroup$ – Jimmy Lee Nov 8 '15 at 10:10