Visualizing Quaternions
Andrew J. Hanson, Indiana University
2004-2005

quatfrenetintgrl.tex
Figure H.1
  -show two quaternion curve integral examples

Utilities:

Set correct current directory.

SetDirectory[QuatBookDir]

<< QuatBookUtils`

Set Local Export directory for expected figures in Figure H.1
mathka/qgray-out1.eps
mathka/qgray-out2.eps

SetDirectory["../mathka"]

FULL FRAME INTEGRALS - Gray's style

This is the Full Frenet Frame integral, using Alfred Gray's book's code,p 223-224
(Modern Differential Geometry of Curves and Surfaces, 2nd Ed, CRC Press, 1998)

\(\(\(plotintrinsic3d[{kk_, 
            tt_}, {a_:  0, {p1_:  0, p2_:  0, p3_:  0}, {q1_:  1, q2_:  0, 
              q3_:  0}, {r1_:  0, r2_:  1, r3_:  0}}, {smin_:  10, 
            smax_:  10}, opts___] := 
        ParametricPlot3D[
          Module[{x1, x2, x3, t1, t2, t3, n1, n2, n3, b1, b2, 
                b3}, {x1[s], x2[s], x3[s]} /. 
                NDSolve[{
\(x1'\)[ss] == 
                      t1[ss], 
\(x2'\)[ss] == 
                      t2[ss], 
\(x3'\)[ss] == 
                      t3[ss], 
\(t1'\)[ss] == 
                      kk[ss]\ n1[ss], 
\(t2'\)[ss] == 
                      kk[ss]\ n2[ss], 
\(t3'\)[ss] == 
                      kk[ss]\ n3[ss], 
\(n1'\)[
                        ss] == \(-kk[ss]\)\ t1[ss] + 
                        tt[ss]\ b1[ss], 
\(n2'\)[
                        ss] == \(-kk[ss]\)\ t2[ss] + 
                        tt[ss]\ b2[ss], 
\(n3'\)[
                        ss] == \(-kk[ss]\)\ t3[ss] + 
                        tt[ss]\ b3[ss], 
\(b1'\)[
                        ss] == \(-tt[ss]\)\ n1[
                          ss], 
\(b2'\)[
                        ss] == \(-tt[ss]\)\ n2[
                          ss], 
\(b3'\)[
                        ss] == \(-tt[ss]\)\ n3[
                          ss], 
x1[a] == p1, 
                    x2[a] == p2, 
                    x3[a] == p3, 
t1[a] == q1, 
                    t2[a] == q2, 
                    t3[a] == q3, 
n1[a] == r1, 
                    n2[a] == r2, 
                    n3[a] == r3, 
b1[a] == 
                      q2*r3 - q3*r2, b2[a] == q3*r1 - q1*r3, 
                    b3[a] == q1*r2 - q2*r1}, {x1, x2, x3, t1, t2, t3, 
                    n1, n2, n3, b1, b2, b3}, 
{ss, smin, 
                    smax}]] // Evaluate, 
{s, smin, smax}, 
          opts];\)\(
\)
    \)\)

\(\(\(plotintrinsic3d[{Abs[#] &,  .3 &}, {0, {0, 0, 0}, {1, 0, 0}, {0, 1, 
          0}}, {\(-10\), 10}, Axes -> None, 
      PlotPoints -> 500]\)\(
\)
    \)\)

\(\(\(plotintrinsic3d[{1.3\  &, \  .5\ Sin[#1]\  &}, {0, {0, 0, 0}, {1, 
          0, 0}, {0, 1, 0}}, {0, 4\ Pi}, Axes -> None, 
      PlotPoints -> 200]\)\(
\)
    \)\)

Quaternion version of the following problem: 
Given the curvature and torsion, find the curve.
- Quaternion frame equation version,
modeled after the full Frenet frame version,
"plotintrinsic3d"
in Alfred Gray's "Modern Differential Geometry
of Curves and Surfaces"  1st and 2nd editions
by Andrew Hanson, Computer Science Dept.,
    Indiana University.  (1994)

Put in Quaternion Frame equations, model after Gray's integration
of the complete 9-component Frenet-Serret equations:
Initial parameters are in the list in 2nd argument:
    sz = curve param value at which BC are specified
    qplot[] shows just the quaternions.
    qplot3dx[] takes initial curve coordinates and finds the
       curve in 3-space with the indicated curvatures as well.

qplot[{k1_, k2_, 
            k3_}, {sz_:  0, {qz0_:  1, qz1_:  0, qz2_:  0, 
              qz3_:  0}}, {smin_:  0, smax_:  1}, angle_:  0, opts___]:=ParametricPlot3D[Evaluate[Module[{q0, q1, q2, q3},{q1[s], q2[s], 
                      N[Cos[angle] q3[s] + Sin[angle] q0[s]]}/.NDSolve[{q0'[ss]==(1/2) (-k2[ss] q1[ss] - 
                                    k3[ss] q2[ss] + k1[ss] q3[ss]),q1'[ss]==(1/2) (k2[ss] q0[ss] - 
                                    k1[ss] q2[ss] + k3[ss] q3[ss]),q2'[ss]==(1/2) (k3[ss] q0[ss] + 
                                    k1[ss] q1[ss] + k2[ss] q3[ss]),q3'[ss]==(1/2) (-k1[ss] q0[ss] - 
                                    k3[ss] q1[ss] - k2[ss] q2[ss]),q0[sz] == qz0,q1[sz] == qz1,q2[sz] == qz2,q3[sz] == qz3},{q0, q1, q2, q3},{ss, smin, smax}]]],{s, smin, smax},opts];

qplot3dx[{k1_, k2_, 
            k3_}, {sz_:  0, {xz1_:  0, xz2_:  0, xz3_:  0}, {qz0_:  1, 
              qz1_:  0, qz2_:  0, qz3_:  0}}, {smin_:  0, smax_:  1}, 
          opts___]:=ParametricPlot3D[Evaluate[Module[{x1, x2, x3, q0, q1, q2, q3},{x1[s], x2[s], x3[s]}/.NDSolve[{q0'[ss]==(1/2) (-k2[ss] q1[ss] - 
                                    k3[ss] q2[ss] + k1[ss] q3[ss]),q1'[ss]==(1/2) (k2[ss] q0[ss] - 
                                    k1[ss] q2[ss] + k3[ss] q3[ss]),q2'[ss]==(1/2) (k3[ss] q0[ss] + 
                                    k1[ss] q1[ss] + k2[ss] q3[ss]),q3'[ss]==(1/2) (-k1[ss] q0[ss] - 
                                    k3[ss] q1[ss] - k2[ss] q2[ss]),x1'[ss]==q0[ss]^2 + q1[ss]^2 - q2[ss]^2 - 
                                q3[ss]^2,x2'[ss]==2 q1[ss] q2[ss] + 
                                2 q0[ss] q3[ss],x3'[ss]==2 q3[ss] q1[ss] - 
                                2 q0[ss] q2[ss],x1[sz] == xz1,x2[sz] == xz2,x3[sz] == xz3,q0[sz] == qz0,q1[sz] == qz1,q2[sz] == qz2,q3[sz] == qz3},{x1, x2, x3, q0, q1, q2, q3},
{ss, smin, smax}]]],
{s, smin, smax},opts];

Examples:
Gray: figures on p. 147. (1st edition)  . p224 (2nd edition)
 My sign convention reverses the curvature;
in general, there are three curvatures, kx, ky, and kz, which is zero
for the Frenet frame.
  The second figure seems to be incorrect in first edition of the book. My version
  is correct; in fact, it has been corrected to match mine in the second edition.

\(qout1\  = \ 
      qplot[{\(-Abs[#1]\) &,  .3 &, 0 &}, {0, {1, 0, 0, 0}}, {0, 2  π}, 
        0, AxesLabel -> {x, y, z}, 
	
        PlotLabel -> "3D projection of the quaternions alone", 
	
        PlotRange -> {{\(-1\), 1}, {\(-1\), 1}, {\(-1\), 1}}, 
        PlotPoints -> 100]\)

out1  =  
      qplot3dx[{-Abs[#1] &, 0.3 &, 
          0 &}, {0, {0, 0, 0}, {1, 0, 0, 0}}, {-10, 10}, 
        AxesLabel -> {x, y, z}, PlotPoints -> 500]

EXPORT IT

Export["qgray-out1.eps", out1, "EPS"]

\(qout2\  = \ 
      qplot[{\(-1.3\) &,  .5\ Sin[#1] &, 0 &}, {0, {1, 0, 0, 0}}, {0, 
          4  π}, 0, AxesLabel -> {x, y, z}, 
	
        PlotLabel -> "3D projection of the quaternions alone", 
	
        PlotRange -> {{\(-1\), 1}, {\(-1\), 1}, {\(-1\), 1}}, 
        PlotPoints -> 100]\)

out2  =  
      qplot3dx[{-1.3 &,  .5 Sin[#1] &, 
          0 &}, {0, {0, 0, 0}, {1, 0, 0, 0}}, {0, 4 π}, 
        AxesLabel -> {x, y, z}, PlotPoints -> 200]

EXPORT IT

Export["qgray-out2.eps", out2, "EPS"]