ntpbooij

5 Reputation

0 Badges

9 years, 304 days
Maritime Institute Willem Barentsz
Senior lecturer mathematics

MaplePrimes Activity


These are questions asked by ntpbooij

Dear reader,

Have to create digital questions in Mobius on quaternions. Aim is to teach students of robot engineering about rotations besides the matrix rotations. Made some code, it works but very simplistic. I could not load a quarternion-toolbox.

Any suggestions?

# quaternion product
# define two vecotrs p and q:
$p0=range(3,3,1);
$px=range(1,1,1);
$py=range(-2,-2,1);
$pz=range(1,1,1);
$q0=range(2,2,1);
$qx=range(-1,-1,1);
$qy=range(2,2,1);
$qz=range(3,3,1);
$p=maple("Vector([$px,$py,$pz])");
$q=maple("Vector([$qx,$qy,$qz])");
$displayp=maple("printf(MathML:-ExportPresentation($p))");
$displayq=maple("printf(MathML:-ExportPresentation($q))");
# p.q=p0.q0-(p.q)+p0.q+q0.p+p*q
# scalar part
$dot=maple("LinearAlgebra[DotProduct]($p,$q,conjugate=false)");
$scalar_part=$p0*$q0-$dot;
# vector part
$cross=maple("LinearAlgebra[CrossProduct]($p,$q)");
$p0q=maple("LinearAlgebra[MatrixMatrixMultiply]($p0,$q)");
$q0p=maple("LinearAlgebra[MatrixMatrixMultiply]($q0,$p)");
$pq=maple("LinearAlgebra[VectorAdd]($p0q,$q0p)");
$vector_part=maple("LinearAlgebra[VectorAdd]($pq,$cross)");
$displayvector_part=maple("printf(MathML:-ExportPresentation($vector_part))");
# unit vectors
$i=maple("Vector([1,0,0])");
$j=maple("Vector([0,1,0])");
$k=maple("Vector([0,0,1])");
# generate answers
$x=maple("LinearAlgebra[DotProduct]($vector_part,$i)");
$y=maple("LinearAlgebra[DotProduct]($vector_part,$j)");
$z=maple("LinearAlgebra[DotProduct]($vector_part,$k)");
 

Best regards,

Nico Booij

Page 1 of 1