Sory, I forgot to tell you a great thanks for the code. ;-)

Alan Bromborsky a écrit :
> projetmbc wrote:
>   
>> Hello,
>> is-it possible to use quaternions with sympy ?
>>
>> Christophe.
>>
>>     
>>   
>>     
> Look at -
>
> http://docs.sympy.org/modules/galgebra/GA/GAsympy.html
>
> and -
>
> http://www.mrao.cam.ac.uk/~clifford/introduction/intro/intro.html
>
> quaternions are the even sub-algebra of the 3D geometric algebra.  See 
> section on
> quaternions in introGA.pdf.  To do 3D rotations we have the following code
>
> #!/usr/bin/python
>
> import sys
> from sympy.galgebra.GA import *
> from sympy.galgebra.latex_ex import *
> from sympy import *
>
> set_main(sys.modules[__name__])
>
> if __name__ == '__main__':
>
>    metric = '1  0  0,'+\
>             '0  1  0,'+\
>             '0  0  1'
>
>    vars = make_symbols('x y z alpha')
>    MV.setup('e',metric,True,vars[:-1])
>    Format()
>    I = MV(1,'pseudo')
>    I.convert_to_blades()
>    print '$I$ Pseudo-Scalar'
>    print 'I =',I
>    u = MV('u','vector') #axis of rotation (unit vector)
>    v = MV('v','vector')  #vector to be rotated
>
>    print 'u =',u
>    print 'v =',v
>    U = I*u #quaternion defining plane of rotation
>    print 'U =',U
>    R = cos(alpha/2)+sin(alpha/2)*U #This is a quaternion
>    print 'R =',R
>    print 'R^{\\dagger} =',R.rev()
>    vp = R*v*R.rev()
>    vp.simplify()
>    MV_format(3)
>    print 'RvR^{\\dagger} =',vp
>    xdvi('rotate.tex')
>
> The output of the code is in the rotate.dvi file.  This can be read with 
> 'xdvi' (I am assuming a linux system).  I did not convert to pdf since 
> the right side of the equations get clipped at the page edge.  With xdvi 
> you can just widen the window until you see the whole equation.  If you 
> run the program without having latex or xdiv simple text output will 
> result and look ugly.  Note that 'u' is the rotation axis (u*u = 1), 
> alpha the rotation angle, and 'v' the vector being rotated.
>
> Note that with geometric algebra it is just as easy to do rotations in 
> N-dimensions!
>
>
>
>
>
>
>
> >
>   


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to