Navigation

    Möbius Community
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    Need help? Ask here!
    Best Practices
    Quick Code Snippets
    Inspiration
    1. Home
    2. ntpbooij
    N
    • Continue chat with ntpbooij
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    ntpbooij

    @ntpbooij

    0
    Reputation
    2
    Posts
    1026
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    ntpbooij Follow

    Posts made by ntpbooij

    • RE: How to use Quaternions in Mobius?

      From ntpbooij: Questions are shared in the Mobius Cloud!

      +Quaterions_Rotation and +Quaternions_multiplication

      The + means question in develop phase.


      posted in Question Creation
      N
      ntpbooij
    • How to use Quaternions in Mobius?

      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 (maple) 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)");

      ###

      # rotation using quaternions
      # unit vectors
      $i=maple("Vector([1,0,0])");
      $j=maple("Vector([0,1,0])");
      $kk=maple("Vector([0,0,1])");
      # rotation axis k:
      $kx=range(1,1,1);
      $ky=range(1,1,1);
      $kz=range(1,1,1);
      $k=maple("Vector([$kx,$ky,$kz])");
      $displayk=maple("printf(MathML:-ExportPresentation($k))");
      # unit vector:
      $length=sqrt($kx^2+$ky^2+$kz^2);
      $u=maple("LinearAlgebra[Multiply](1/$length,$k)");
      $displayu=maple("printf(MathML:-ExportPresentation($u))");
      # rotation angle:
      $angledeg=range(120,120,1);
      $angle=$angledeg*pi/180;
      # quaternion:
      $scalar=cos($angle/2);
      $vector=maple("LinearAlgebra[Multiply](sin($angle/2),$u)");
      $displayvector=maple("printf(MathML:-ExportPresentation($vector))");
      $qx=maple("LinearAlgebra[DotProduct]($vector,$i)");
      $qy=maple("LinearAlgebra[DotProduct]($vector,$j)");
      $qz=maple("LinearAlgebra[DotProduct]($vector,$kk)");
      # base vector (to be rotated around k)
      $bx=range(1,1,1);
      $by=range(0,0,1);
      $bz=range(0,0,1);
      $b=maple("Vector([$bx,$by,$bz])");
      $displayb=maple("printf(MathML:-ExportPresentation($b))");
      # rotation:
      $dot=maple("LinearAlgebra[DotProduct]($u,$b,conjugate=false)");
      $cross=maple("LinearAlgebra[CrossProduct]($u,$b)");
      $term1=maple("LinearAlgebra[Multiply](cos($angle),$b)");
      $displayterm1=maple("printf(MathML:-ExportPresentation($term1))");
      $term2=maple("LinearAlgebra[Multiply]((1-cos($angle))*$dot,$u)");
      $displayterm2=maple("printf(MathML:-ExportPresentation($term2))");
      $term3=maple("LinearAlgebra[Multiply](sin($angle),$cross)");
      $displayterm3=maple("printf(MathML:-ExportPresentation($term3))");
      $L1=maple("LinearAlgebra[VectorAdd]($term1,$term2)");
      $L=maple("LinearAlgebra[VectorAdd]($L1,$term3)");
      $displayL=maple("printf(MathML:-ExportPresentation($L))");
      # generate answers
      $Lx=maple("LinearAlgebra[DotProduct]($L,$i)");
      $Ly=maple("LinearAlgebra[DotProduct]($L,$j)");
      $Lz=maple("LinearAlgebra[DotProduct]($L,$kk)");

      Best regards,

      Nico Booij

      posted in Question Creation
      N
      ntpbooij

    About Us

    This forum aims to connect DigitalEd's users. For official Möbius support, please see https://www.digitaled.com/support/.

    Contact Info

    630 Weber Street North
    Suite 100
    Waterloo, ON Canada
    N2V 2N2
    .
    1.888.355.4511
    info@digitaled.com

    Community

    Quick Links

    Categories Recent Tags Popular Users Search

    Möbius Community Forum

    © DigitalEd, a division of Digital Education Ltd. 2018.   •  Terms of Use | Privacy | Trademarks

    Powered by NodeBB Forums | Contributors