+
    õäûj{¹  ã                   ó  € ^ RI Ht ^ RIHt ^ RIHt ^ RIHtHtH	t	H
t
 ^ RIHtHt ^ RIHt ^ RIHtHtHt ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHtH t  ^ RI!H"t" ^ RI#H$t$H%t% ^ RI&H't' ^ RI(H)t) R t*R t+ ! R R]"4      t,R# )é    )ÚRational)ÚS)Úis_eq)Ú	conjugateÚimÚreÚsign)ÚexpÚlog)Úsqrt)ÚacosÚasinÚatan2)ÚcosÚsin)Útrigsimp©Ú	integrate)ÚMutableDenseMatrix)ÚsympifyÚ_sympify)ÚExpr)Ú	fuzzy_notÚfuzzy_or)Úas_int)Úprec_to_dpsc                óP  € Ve¢   VP                   '       dŽ   VP                  RJ d   \        R4      h\        ;QJ d    R V  4       F  '       d   K   RM	  RM! R V  4       4      pV'       d5   \	        V^,          \        R V  4       4      4      RJ d   \        R4      hR# R# R# R# )z$validate if input norm is consistentNFzInput norm must be positive.c              3   ód   "  € T F&  qP                   ;'       d    VP                  R J x € K(  	  R# 5i)TN)Ú	is_numberÚis_real©Ú.0Úis   & ÚUC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\algebras\quaternion.pyÚ	<genexpr>Ú_check_norm.<locals>.<genexpr>   s&   é € ÐLÁ8¸aŸ™×9Ð9¨¯	©	°TÐ(9Ô9Ã8ùs   ‚0™0Tc              3   ó2   "  € T F  q^,          x € K  	  R# 5i)é   N© r!   s   & r$   r%   r&      s   é € Ð+C¹(°Q¨q¯DªD»(ùs   ‚zIncompatible value for norm.)r   Úis_positiveÚ
ValueErrorÚallr   Úsum)ÚelementsÚnormÚ	numericals   && r$   Ú_check_normr1      s†   € àÒ˜DŸNŸN˜NØ×Ñ˜uÓ$ÜÐ;Ó<Ð<ç“CÑLÁ8ÓL—C—C’CÑLÁ8ÓLÓLˆ	ßœ˜t Q�w¬Ñ+C¹(Ó+CÓ(CÓDÈÓMÜÐ;Ó<Ð<ñ N‰9ñ +Ñó    c                óú  € \        V 4      \        8w  d   \        R4      h\        V 4      ^8w  d   \        RP	                  V 4      4      hV P                  4       pV P                  4       pV'       g   V'       g   \        R4      hV P                  4       w  r4pW48X  g   WE8X  d   \        R4      h\        V 4      \        R4      ,
          pV'       d*   \        RP	                  RP                  V4      4      4      hV# )zGvalidate seq and return True if seq is lowercase and False if uppercasezExpected seq to be a string.zExpected 3 axes, got `{}`.zkseq must either be fully uppercase (for extrinsic rotations), or fully lowercase, for intrinsic rotations).z"Consecutive axes must be differentÚxyzXYZzNExpected axes from `seq` to be from ['x', 'y', 'z'] or ['X', 'Y', 'Z'], got {}Ú )
ÚtypeÚstrr+   ÚlenÚformatÚisupperÚislowerÚlowerÚsetÚjoin)ÚseqÚ	intrinsicÚ	extrinsicr#   ÚjÚkÚbads   &      r$   Ú_is_extrinsicrE      sÐ   € äˆCƒy”CÔÜÐ7Ó8Ð8Ü
ˆ3ƒx�1„}ÜÐ5×<Ñ<¸SÓAÓBÐBà—‘“€IØ—‘“€IßŸÜð 'ó (ð 	(ð �i‰i‹k�G€Aˆ!Ø	Œ�A”FÜÐ=Ó>Ð>ä
ˆc‹(”S˜“]Õ
"€Cß
Üð "ç"(¡&¨¯©°«Ó"6ó8ð 	8ð Ðr2   c                   ó  a a€ ] tR t^:t oRtRtRtR<V 3R lltR t]	R 4       t
]	R 4       t]	R 4       t]	R	 4       t]	R
 4       t]	R 4       t]	R 4       tR=R lt]R 4       t]R 4       tR>R lt]R 4       t]R 4       tR tR tR tR tR tR tR tR tR t R t!R t"R t#R t$]%R  4       t&R! t'R" t(R# t)R$ t*R% t+R& t,R' t-R( t.R) t/R* t0R+ t1]%R, 4       t2R- t3R?R. lt4R/ t5R0 t6R1 t7R2 t8R3 t9R4 t:R5 t;]R6 4       t<R7 t=R8 t>R9 t?R: t@R;tAVtBV ;tC# )@Ú
Quaternionaf  Provides basic quaternion operations.
Quaternion objects can be instantiated as ``Quaternion(a, b, c, d)``
as in $q = a + bi + cj + dk$.

Parameters
==========

norm : None or number
    Pre-defined quaternion norm. If a value is given, Quaternion.norm
    returns this pre-defined value instead of calculating the norm

Examples
========

>>> from sympy import Quaternion
>>> q = Quaternion(1, 2, 3, 4)
>>> q
1 + 2*i + 3*j + 4*k

Quaternions over complex fields can be defined as:

>>> from sympy import Quaternion
>>> from sympy import symbols, I
>>> x = symbols('x')
>>> q1 = Quaternion(x, x**3, x, x**2, real_field = False)
>>> q2 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False)
>>> q1
x + x**3*i + x*j + x**2*k
>>> q2
(3 + 4*I) + (2 + 5*I)*i + 0*j + (7 + 8*I)*k

Defining symbolic unit quaternions:

>>> from sympy import Quaternion
>>> from sympy.abc import w, x, y, z
>>> q = Quaternion(w, x, y, z, norm=1)
>>> q
w + x*i + y*j + z*k
>>> q.norm()
1

References
==========

.. [1] https://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/
.. [2] https://en.wikipedia.org/wiki/Quaternion

g      &@Fc                ó  <€ \        \        WW434      w  rr4\        ;QJ d    R  WW43 4       F  '       g   K   RM	  RM! R  WW43 4       4      '       d   \        R4      h\        SV `  WW#V4      pWWn        VP                  V4       V# )c              3   ó<   "  € T F  qP                   R J x € K  	  R# 5i)FN)Úis_commutativer!   s   & r$   r%   Ú%Quaternion.__new__.<locals>.<genexpr>r   s   é € Ð?±,¨Q×Ñ 5Õ(³,ùs   ‚TFz arguments have to be commutative)Úmapr   Úanyr+   ÚsuperÚ__new__Ú_real_fieldÚset_norm)	ÚclsÚaÚbÚcÚdÚ
real_fieldr/   ÚobjÚ	__class__s	   &&&&&&& €r$   rO   ÚQuaternion.__new__o   st   ø€ Üœ 1¨ ,Ó/‰
ˆˆaç‹3Ñ?°1¸±,Ó?�3�3Š3Ñ?°1¸±,Ó?×?Ò?ÜÐ?Ó@Ð@Ü‰g‰o˜c a¨AÓ.ˆØ$ŒØ�‰�TÔØˆ
r2   c                óT   € \        V4      p\        V P                  V4       Wn        R# )a  Sets norm of an already instantiated quaternion.

Parameters
==========

norm : None or number
    Pre-defined quaternion norm. If a value is given, Quaternion.norm
    returns this pre-defined value instead of calculating the norm

Examples
========

>>> from sympy import Quaternion
>>> from sympy.abc import a, b, c, d
>>> q = Quaternion(a, b, c, d)
>>> q.norm()
sqrt(a**2 + b**2 + c**2 + d**2)

Setting the norm:

>>> q.set_norm(1)
>>> q.norm()
1

Removing set norm:

>>> q.set_norm(None)
>>> q.norm()
sqrt(a**2 + b**2 + c**2 + d**2)

N)r   r1   ÚargsÚ_norm)Úselfr/   s   &&r$   rQ   ÚQuaternion.set_normy   s!   € ô@ �t‹}ˆÜ�D—I‘I˜tÔ$ØŽ
r2   c                ó(   € V P                   ^ ,          # )r   ©r\   ©r^   s   &r$   rS   ÚQuaternion.a�   ó   € à�y‰y˜�|Ðr2   c                ó(   € V P                   ^,          # )é   ra   rb   s   &r$   rT   ÚQuaternion.b¡   rd   r2   c                ó(   € V P                   ^,          # )r(   ra   rb   s   &r$   rU   ÚQuaternion.c¥   rd   r2   c                ó(   € V P                   ^,          # )é   ra   rb   s   &r$   rV   ÚQuaternion.d©   rd   r2   c                ó   € V P                   # ©N)rP   rb   s   &r$   rW   ÚQuaternion.real_field­   s   € à×ÑÐr2   c           	     óŒ  € \        V P                  V P                  ) V P                  ) V P                  ) .V P                  V P                  V P                  ) V P                  .V P                  V P                  V P                  V P                  ) .V P                  V P                  ) V P                  V P                  ..4      # )aŒ  Returns 4 x 4 Matrix equivalent to a Hamilton product from the
left. This can be useful when treating quaternion elements as column
vectors. Given a quaternion $q = a + bi + cj + dk$ where a, b, c and d
are real numbers, the product matrix from the left is:

.. math::

    M  =  \begin{bmatrix} a  &-b  &-c  &-d \\
                          b  & a  &-d  & c \\
                          c  & d  & a  &-b \\
                          d  &-c  & b  & a \end{bmatrix}

Examples
========

>>> from sympy import Quaternion
>>> from sympy.abc import a, b, c, d
>>> q1 = Quaternion(1, 0, 0, 1)
>>> q2 = Quaternion(a, b, c, d)
>>> q1.product_matrix_left
Matrix([
[1, 0,  0, -1],
[0, 1, -1,  0],
[0, 1,  1,  0],
[1, 0,  0,  1]])

>>> q1.product_matrix_left * q2.to_Matrix()
Matrix([
[a - d],
[b - c],
[b + c],
[a + d]])

This is equivalent to:

>>> (q1 * q2).to_Matrix()
Matrix([
[a - d],
[b - c],
[b + c],
[a + d]])
©ÚMatrixrS   rT   rU   rV   rb   s   &r$   Úproduct_matrix_leftÚQuaternion.product_matrix_left±   s“   € ôX Ø—‘˜$Ÿ&™&˜ 4§6¡6 '¨D¯F©F¨7Ð3Ø—‘˜Ÿ™ $§&¡& ¨$¯&©&Ð1Ø—‘˜Ÿ™ §¡¨$¯&©&¨Ð1Ø—‘˜$Ÿ&™&˜ $§&¡&¨$¯&©&Ð1ð	3ó 4ð 	4r2   c           	     óŒ  € \        V P                  V P                  ) V P                  ) V P                  ) .V P                  V P                  V P                  V P                  ) .V P                  V P                  ) V P                  V P                  .V P                  V P                  V P                  ) V P                  ..4      # )a%  Returns 4 x 4 Matrix equivalent to a Hamilton product from the
right. This can be useful when treating quaternion elements as column
vectors. Given a quaternion $q = a + bi + cj + dk$ where a, b, c and d
are real numbers, the product matrix from the left is:

.. math::

    M  =  \begin{bmatrix} a  &-b  &-c  &-d \\
                          b  & a  & d  &-c \\
                          c  &-d  & a  & b \\
                          d  & c  &-b  & a \end{bmatrix}


Examples
========

>>> from sympy import Quaternion
>>> from sympy.abc import a, b, c, d
>>> q1 = Quaternion(a, b, c, d)
>>> q2 = Quaternion(1, 0, 0, 1)
>>> q2.product_matrix_right
Matrix([
[1, 0, 0, -1],
[0, 1, 1, 0],
[0, -1, 1, 0],
[1, 0, 0, 1]])

Note the switched arguments: the matrix represents the quaternion on
the right, but is still considered as a matrix multiplication from the
left.

>>> q2.product_matrix_right * q1.to_Matrix()
Matrix([
[ a - d],
[ b + c],
[-b + c],
[ a + d]])

This is equivalent to:

>>> (q1 * q2).to_Matrix()
Matrix([
[ a - d],
[ b + c],
[-b + c],
[ a + d]])
rq   rb   s   &r$   Úproduct_matrix_rightÚQuaternion.product_matrix_rightã   s“   € ôb Ø—‘˜$Ÿ&™&˜ 4§6¡6 '¨D¯F©F¨7Ð3Ø—‘˜Ÿ™ §¡¨$¯&©&¨Ð1Ø—‘˜$Ÿ&™&˜ $§&¡&¨$¯&©&Ð1Ø—‘˜Ÿ™ $§&¡& ¨$¯&©&Ð1ð	3ó 4ð 	4r2   c                ót   € V'       d   \        V P                  R,          4      # \        V P                  4      # )a³  Returns elements of quaternion as a column vector.
By default, a ``Matrix`` of length 4 is returned, with the real part as the
first element.
If ``vector_only`` is ``True``, returns only imaginary part as a Matrix of
length 3.

Parameters
==========

vector_only : bool
    If True, only imaginary part is returned.
    Default value: False

Returns
=======

Matrix
    A column vector constructed by the elements of the quaternion.

Examples
========

>>> from sympy import Quaternion
>>> from sympy.abc import a, b, c, d
>>> q = Quaternion(a, b, c, d)
>>> q
a + b*i + c*j + d*k

>>> q.to_Matrix()
Matrix([
[a],
[b],
[c],
[d]])


>>> q.to_Matrix(vector_only=True)
Matrix([
[b],
[c],
[d]])

:rf   NN)rr   r\   )r^   Úvector_onlys   &&r$   Ú	to_MatrixÚQuaternion.to_Matrix  s*   € ÷X Ü˜$Ÿ)™) B�-Ó(Ð(ä˜$Ÿ)™)Ó$Ð$r2   c                ó¢   € \        V4      pV^8w  d"   V^8w  d   \        RP                  V4      4      hV^8X  d   \        ^ .VO5!  # \        V!  # )aK  Returns quaternion from elements of a column vector`.
If vector_only is True, returns only imaginary part as a Matrix of
length 3.

Parameters
==========

elements : Matrix, list or tuple of length 3 or 4. If length is 3,
    assume real part is zero.
    Default value: False

Returns
=======

Quaternion
    A quaternion created from the input elements.

Examples
========

>>> from sympy import Quaternion
>>> from sympy.abc import a, b, c, d
>>> q = Quaternion.from_Matrix([a, b, c, d])
>>> q
a + b*i + c*j + d*k

>>> q = Quaternion.from_Matrix([b, c, d])
>>> q
0 + b*i + c*j + d*k

z7Input elements must have length 3 or 4, got {} elements)r8   r+   r9   rG   )rR   r.   Úlengths   && r$   Úfrom_MatrixÚQuaternion.from_MatrixK  sZ   € ôB �X“ˆØ�QŒ;˜6 Qœ;Üð (ß(.©¨v«ó8ð 8ð �QŒ;Ü˜aÐ+ (Ó+Ð+ä˜xÑ(Ð(r2   c                ó(  € \        V4      ^8w  d   \        R4      h\        V4      pVP                  4       w  rEpR Uu. uF  qwV8X  d   ^M^ NK  	  ppR Uu. uF  qwV8X  d   ^M^ NK  	  p	pR Uu. uF  qwV8X  d   ^M^ NK  	  p
pV P	                  W�^ ,          4      pV P	                  W‘^,          4      pV P	                  W¡^,          4      pV'       d   \        WÜ,          V,          4      # \        W¼,          V,          4      # u upi u upi u upi )aò  Returns quaternion equivalent to rotation represented by the Euler
angles, in the sequence defined by ``seq``.

Parameters
==========

angles : list, tuple or Matrix of 3 numbers
    The Euler angles (in radians).
seq : string of length 3
    Represents the sequence of rotations.
    For extrinsic rotations, seq must be all lowercase and its elements
    must be from the set ``{'x', 'y', 'z'}``
    For intrinsic rotations, seq must be all uppercase and its elements
    must be from the set ``{'X', 'Y', 'Z'}``

Returns
=======

Quaternion
    The normalized rotation quaternion calculated from the Euler angles
    in the given sequence.

Examples
========

>>> from sympy import Quaternion
>>> from sympy import pi
>>> q = Quaternion.from_euler([pi/2, 0, 0], 'xyz')
>>> q
sqrt(2)/2 + sqrt(2)/2*i + 0*j + 0*k

>>> q = Quaternion.from_euler([0, pi/2, pi] , 'zyz')
>>> q
0 + (-sqrt(2)/2)*i + 0*j + sqrt(2)/2*k

>>> q = Quaternion.from_euler([0, pi/2, pi] , 'ZYZ')
>>> q
0 + sqrt(2)/2*i + 0*j + sqrt(2)/2*k

z3 angles must be given.Úxyz)r8   r+   rE   r<   Úfrom_axis_angler   )rR   Úanglesr?   rA   r#   rB   rC   ÚnÚeiÚejÚekÚqiÚqjÚqks   &&&           r$   Ú
from_eulerÚQuaternion.from_eulerv  sý   € ôV ˆv‹;˜!ÔÜÐ6Ó7Ð7ä! #Ó&ˆ	Ø—)‘)“+‰ˆˆañ +0Ó0©% Q˜”6‰a˜qÒ ©%ˆÐ0Ù*/Ó0©% Q˜”6‰a˜qÒ ©%ˆÐ0Ù*/Ó0©% Q˜”6‰a˜qÒ ©%ˆÐ0ð × Ñ  ¨A¥YÓ/ˆØ× Ñ  ¨A¥YÓ/ˆØ× Ñ  ¨A¥YÓ/ˆçÜ˜B�G b�LÓ)Ð)ä˜B�G b�LÓ)Ð)ùò 1ùÚ0ùÚ0s   ¾DÁD
Á0Dc           	     óX	  € V P                  4       '       d   \        R4      h. ROp\        V4      pVP                  4       w  rgpRP	                  V4      ^,           pRP	                  V4      ^,           pRP	                  V4      ^,           pV'       g   Y†r†Wh8H  p	V	'       d   ^V,
          V,
          pWg,
          Wx,
          ,          W†,
          ,          ^,          p
V P
                  V P                  V P                  V P                  .pV^ ,          pW¶,          pW·,          pW¸,          V
,          pV	'       g"   WÎ,
          Wß,           Wì,           Wý,
          3w  rÍrïV'       dÄ   V	'       d[   V P                  4       ^,          p\        WÌ,          WÝ,          ,           Wî,          ,
          Wÿ,          ,
          V,          4      V^&   Má^V P                  4       ^,          ,          p\        Wî,          Wÿ,          ,           WÌ,          ,
          WÝ,          ,
          V,          4      V^&   M€^\        \        Wî,          Wÿ,          ,           4      \        WÌ,          WÝ,          ,           4      4      ,          V^&   V	'       g+   V^;;,          \        P                  ^,          ,          uu&   ^ p\!        V\        P"                  4      '       d#   \!        V\        P"                  4      '       d   ^p\!        V\        P"                  4      '       d#   \!        V\        P"                  4      '       d   ^pV^ 8X  d±   V'       d>   \        WÜ4      \        Wþ4      ,           V^ &   \        WÜ4      \        Wþ4      ,
          V^&   Mð\        WÞ,          WÏ,          ,           WÎ,          Wß,          ,
          4      V^ &   \        WÞ,          WÏ,          ,
          WÎ,          Wß,          ,           4      V^&   M…\        P"                  V^V'       * ,          &   V^8X  d   ^\        WÜ4      ,          V^V,          &   MB^\        Wþ4      ,          V^V,          &   T^V,          ;;,          V'       d   RM^,          uu&   V	'       g   V^ ;;,          V
,          uu&   V'       d   \%        VRRR1,          4      # \%        V4      # )a  Returns Euler angles representing same rotation as the quaternion,
in the sequence given by ``seq``. This implements the method described
in [1]_.

For degenerate cases (gymbal lock cases), the third angle is
set to zero.

Parameters
==========

seq : string of length 3
    Represents the sequence of rotations.
    For extrinsic rotations, seq must be all lowercase and its elements
    must be from the set ``{'x', 'y', 'z'}``
    For intrinsic rotations, seq must be all uppercase and its elements
    must be from the set ``{'X', 'Y', 'Z'}``

angle_addition : bool
    When True, first and third angles are given as an addition and
    subtraction of two simpler ``atan2`` expressions. When False, the
    first and third angles are each given by a single more complicated
    ``atan2`` expression. This equivalent expression is given by:

    .. math::

        \operatorname{atan_2} (b,a) \pm \operatorname{atan_2} (d,c) =
        \operatorname{atan_2} (bc\pm ad, ac\mp bd)

    Default value: True

avoid_square_root : bool
    When True, the second angle is calculated with an expression based
    on ``acos``, which is slightly more complicated but avoids a square
    root. When False, second angle is calculated with ``atan2``, which
    is simpler and can be better for numerical reasons (some
    numerical implementations of ``acos`` have problems near zero).
    Default value: False


Returns
=======

Tuple
    The Euler angles calculated from the quaternion

Examples
========

>>> from sympy import Quaternion
>>> from sympy.abc import a, b, c, d
>>> euler = Quaternion(a, b, c, d).to_euler('zyz')
>>> euler
(-atan2(-b, c) + atan2(d, a),
 2*atan2(sqrt(b**2 + c**2), sqrt(a**2 + d**2)),
 atan2(-b, c) + atan2(d, a))


References
==========

.. [1] https://doi.org/10.1371/journal.pone.0276302

z(Cannot convert a quaternion with norm 0.r�   N)r   r   r   éÿÿÿÿ)Úis_zero_quaternionr+   rE   r<   ÚindexrS   rT   rU   rV   r/   r   r   r   r   r   ÚPir   ÚZeroÚtuple)r^   r?   Úangle_additionÚavoid_square_rootrƒ   rA   r#   rB   rC   Ú	symmetricr	   r.   rS   rT   rU   rV   Ún2Úcases   &&&&              r$   Úto_eulerÚQuaternion.to_euler¶  s4  € ð@ ×"Ñ"×$Ò$ÜÐGÓHÐHâˆä! #Ó&ˆ	Ø—)‘)“+‰ˆˆað �K‰K˜‹N˜QÕˆØ�K‰K˜‹N˜QÕˆØ�K‰K˜‹N˜QÕˆçØˆqð ‘Fˆ	ßØ�A•˜•	ˆAð •˜!�%Õ  A¥EÕ*¨aÕ/ˆð —F‘F˜DŸF™F D§F¡F¨D¯F©FÐ3ˆØ�Q�KˆØ�KˆØ�KˆØ�K˜$ÕˆçØ� ¥ q¥u¨a­eÐ3‰JˆA�!çßØ—Y‘Y“[ !•^�Ü  !¥%¨!­%¥-°!µ%Õ"7¸!½%Õ"?À2Õ!EÓF��q’	à˜Ÿ™› a�Õ'�Ü  !¥%¨!­%¥-°!µ%Õ"7¸!½%Õ"?À2Õ!EÓF��q’	àœE¤$ q¥u¨q­u¥}Ó"5´t¸A½EÀAÅE½MÓ7JÓKÕKˆF�1‰IßØ�q—	œQŸT™T A�XÕ%“	ð ˆÜ�”A—F‘F×Ò¤ a¬¯©× 0Ò 0ØˆDÜ�”A—F‘F×Ò¤ a¬¯©× 0Ò 0ØˆDà�1Œ9ßÜ! !›K¬%°«+Õ5��q‘	Ü! !›K¬%°«+Õ5��q’	ä! !¥#¨­¥)¨Q­S°1µ3­YÓ7��q‘	Ü! !¥#¨­¥)¨Q­S°1µ3­YÓ7��q’	ô +,¯&©&ˆF�1˜IœÕ&Ñ'Ø�qŒyØ()¬E°!«K­��q˜9•}Ò%à()¬E°!«K­��q˜9•}Ñ%Ø�q˜9•}×%·	©"¸qÕAÓ%÷ Ø�1�I˜Õ‹IçÜ˜¡ " �Ó&Ð&ä˜“=Ð r2   c                óX  € Vw  r4p\        V^,          V^,          ,           V^,          ,           4      pW6,          WF,          WV,          rTp\        V\        P                  ,          4      p\	        V\        P                  ,          4      pW7,          p	WG,          p
WW,          pV ! W‰W«4      # )a8  Returns a rotation quaternion given the axis and the angle of rotation.

Parameters
==========

vector : tuple of three numbers
    The vector representation of the given axis.
angle : number
    The angle by which axis is rotated (in radians).

Returns
=======

Quaternion
    The normalized rotation quaternion calculated from the given axis and the angle of rotation.

Examples
========

>>> from sympy import Quaternion
>>> from sympy import pi, sqrt
>>> q = Quaternion.from_axis_angle((sqrt(3)/3, sqrt(3)/3, sqrt(3)/3), 2*pi/3)
>>> q
1/2 + 1/2*i + 1/2*j + 1/2*k

)r   r   r   ÚHalfr   )rR   ÚvectorÚangleÚxÚyÚzr/   ÚsrS   rT   rU   rV   s   &&&         r$   r‚   ÚQuaternion.from_axis_angleD  s„   € ð8 ‰	ˆˆqÜ�A�q•D˜1˜a�4•K ! Q¥$Õ&Ó'ˆØ•X˜q�x¨­ˆqˆÜ�œŸ™•ÓˆÜ�œŸ™•ÓˆØ�EˆØ�EˆØ�Eˆñ �1˜‹Ðr2   c                ó  € VP                  4       \        ^^4      ,          p\        W!R,          ,           VR,          ,           VR,          ,           4      ^,          p\        W!R,          ,           VR,          ,
          VR,          ,
          4      ^,          p\        W!R,          ,
          VR,          ,           VR,          ,
          4      ^,          p\        W!R,          ,
          VR,          ,
          VR,          ,           4      ^,          pV\        VR,          VR,          ,
          4      ,          pV\        VR,          VR,          ,
          4      ,          pV\        VR,          VR	,          ,
          4      ,          p\	        W4WV4      # )
a÷  Returns the equivalent quaternion of a matrix. The quaternion will be normalized
only if the matrix is special orthogonal (orthogonal and det(M) = 1).

Parameters
==========

M : Matrix
    Input matrix to be converted to equivalent quaternion. M must be special
    orthogonal (orthogonal and det(M) = 1) for the quaternion to be normalized.

Returns
=======

Quaternion
    The quaternion equivalent to given matrix.

Examples
========

>>> from sympy import Quaternion
>>> from sympy import Matrix, symbols, cos, sin, trigsimp
>>> x = symbols('x')
>>> M = Matrix([[cos(x), -sin(x), 0], [sin(x), cos(x), 0], [0, 0, 1]])
>>> q = trigsimp(Quaternion.from_rotation_matrix(M))
>>> q
sqrt(2)*sqrt(cos(x) + 1)/2 + 0*i + 0*j + sqrt(2 - 2*cos(x))*sign(sin(x))/2*k

)r   r   )rf   rf   )r(   r(   )r(   rf   )rf   r(   )r   r(   )r(   r   )rf   r   )r   rf   )Údetr   r   r	   rG   )rR   ÚMÚabsQrS   rT   rU   rV   s   &&     r$   Úfrom_rotation_matrixÚQuaternion.from_rotation_matrixo  s  € ð> �u‰u‹wœ  A›Õ&ˆä�˜$�• ! D¥'Õ)¨A¨d­GÕ3Ó4°qÕ8ˆÜ�˜$�• ! D¥'Õ)¨A¨d­GÕ3Ó4°qÕ8ˆÜ�˜$�• ! D¥'Õ)¨A¨d­GÕ3Ó4°qÕ8ˆÜ�˜$�• ! D¥'Õ)¨A¨d­GÕ3Ó4°qÕ8ˆà”�Q�t•W˜q �wÕ&Ó'Õ'ˆØ”�Q�t•W˜q �wÕ&Ó'Õ'ˆØ”�Q�t•W˜q �wÕ&Ó'Õ'ˆä˜! Ó%Ð%r2   c                ó$   € V P                  V4      # rn   ©Úadd©r^   Úothers   &&r$   Ú__add__ÚQuaternion.__add__›  ó   € Ø�x‰x˜‹Ðr2   c                ó$   € V P                  V4      # rn   r«   r­   s   &&r$   Ú__radd__ÚQuaternion.__radd__ž  r±   r2   c                ó2   € V P                  VR,          4      # ©rf   rŽ   r«   r­   s   &&r$   Ú__sub__ÚQuaternion.__sub__¡  s   € Ø�x‰x˜˜b�Ó!Ð!r2   c                ó8   € V P                  V \        V4      4      # rn   ©Ú_generic_mulr   r­   s   &&r$   Ú__mul__ÚQuaternion.__mul__¤  s   € Ø× Ñ  ¤x°£Ó7Ð7r2   c                ó8   € V P                  \        V4      V 4      # rn   rº   r­   s   &&r$   Ú__rmul__ÚQuaternion.__rmul__§  s   € Ø× Ñ ¤¨%£°$Ó7Ð7r2   c                ó$   € V P                  V4      # rn   )Úpow)r^   Úps   &&r$   Ú__pow__ÚQuaternion.__pow__ª  s   € Ø�x‰x˜‹{Ðr2   c                óv   € \        V P                  ) V P                  ) V P                  ) V P                  ) 4      # rn   )rG   rS   rT   rU   rV   rb   s   &r$   Ú__neg__ÚQuaternion.__neg__­  s+   € Ü˜4Ÿ6™6˜' D§F¡F 7¨T¯V©V¨G°d·f±f°WÓ=Ð=r2   c                ó4   € V \        V4      R,          ,          # r¶   ©r   r­   s   &&r$   Ú__truediv__ÚQuaternion.__truediv__°  s   € Ø”g˜e“n bÕ(Õ(Ð(r2   c                ó4   € \        V4      V R,          ,          # r¶   rÊ   r­   s   &&r$   Ú__rtruediv__ÚQuaternion.__rtruediv__³  s   € Ü�u‹~  b¥Õ(Ð(r2   c                ó"   € V P                   ! V!  # rn   r   ©r^   r\   s   &*r$   Ú_eval_IntegralÚQuaternion._eval_Integral¶  s   € Ø�~Š~˜tÑ$Ð$r2   c           
     ó¢   € VP                  R R4       V P                  ! V P                   Uu. uF  q3P                  ! V/ VB NK  	  up!  # u upi )ÚevaluateT)Ú
setdefaultÚfuncr\   Údiff)r^   ÚsymbolsÚkwargsrS   s   &*, r$   rØ   ÚQuaternion.diff¹  sC   € Ø×Ñ˜* dÔ+Ø�yŠyÀÇ	Â	ÓJÁ	¸!Ÿ6š6 7Ð5¨fÔ5Á	ÑJÑKÐKùÒJs   ­Ac                óä  € T p\        V4      p\        V\        4      '       gÕ   VP                  '       di   VP                  '       dW   \        \        V4      VP                  ,           \        V4      VP                  ,           VP                  VP                  4      # VP                  '       d>   \        VP                  V,           VP                  VP                  VP                  4      # \        R4      h\        VP                  VP                  ,           VP                  VP                  ,           VP                  VP                  ,           VP                  VP                  ,           4      # )aÏ  Adds quaternions.

Parameters
==========

other : Quaternion
    The quaternion to add to current (self) quaternion.

Returns
=======

Quaternion
    The resultant quaternion after adding self to other

Examples
========

>>> from sympy import Quaternion
>>> from sympy import symbols
>>> q1 = Quaternion(1, 2, 3, 4)
>>> q2 = Quaternion(5, 6, 7, 8)
>>> q1.add(q2)
6 + 8*i + 10*j + 12*k
>>> q1 + 5
6 + 2*i + 3*j + 4*k
>>> x = symbols('x', real = True)
>>> q1.add(x)
(x + 1) + 2*i + 3*j + 4*k

Quaternions over complex fields :

>>> from sympy import Quaternion
>>> from sympy import I
>>> q3 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False)
>>> q3.add(2 + 3*I)
(5 + 7*I) + (2 + 5*I)*i + 0*j + (7 + 8*I)*k

z<Only commutative expressions can be added with a Quaternion.)r   Ú
isinstancerG   rW   Ú
is_complexr   rS   r   rT   rU   rV   rJ   r+   )r^   r®   Úq1Úq2s   &&  r$   r¬   ÚQuaternion.add½  së   € ðN ˆÜ�U‹^ˆô ˜"œj×)Ò)Ø�}�}ˆ} §§ Ü!¤" R£&¨2¯4©4¥-´°B³¸"¿$¹$µÀÇÁÀbÇdÁdÓKÐKØ×"×"Ð"Ü! "§$¡$¨¥)¨R¯T©T°2·4±4¸¿¹Ó>Ð>ä Ð!_Ó`Ð`ä˜"Ÿ$™$ §¡�+ r§t¡t¨b¯d©d¥{°B·D±D¸2¿4¹4µKÀÇÁØŸD™DõB!ó "ð 	"r2   c                ó8   € V P                  V \        V4      4      # )a  Multiplies quaternions.

Parameters
==========

other : Quaternion or symbol
    The quaternion to multiply to current (self) quaternion.

Returns
=======

Quaternion
    The resultant quaternion after multiplying self with other

Examples
========

>>> from sympy import Quaternion
>>> from sympy import symbols
>>> q1 = Quaternion(1, 2, 3, 4)
>>> q2 = Quaternion(5, 6, 7, 8)
>>> q1.mul(q2)
(-60) + 12*i + 30*j + 24*k
>>> q1.mul(2)
2 + 4*i + 6*j + 8*k
>>> x = symbols('x', real = True)
>>> q1.mul(x)
x + 2*x*i + 3*x*j + 4*x*k

Quaternions over complex fields :

>>> from sympy import Quaternion
>>> from sympy import I
>>> q3 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False)
>>> q3.mul(2 + 3*I)
(2 + 3*I)*(3 + 4*I) + (2 + 3*I)*(2 + 5*I)*i + 0*j + (2 + 3*I)*(7 + 8*I)*k

rº   r­   s   &&r$   ÚmulÚQuaternion.muló  s   € ðN × Ñ  ¤x°£Ó7Ð7r2   c                óN  € \        V \        4      '       g   \        V\        4      '       g	   W,          # \        V \        4      '       g·   VP                  '       d:   V P                  '       d(   \        \	        V 4      \        V 4      ^ ^ 4      V,          # V P                  '       dO   \        WP                  ,          WP                  ,          WP                  ,          WP                  ,          4      # \        R4      h\        V\        4      '       g·   V P                  '       d:   VP                  '       d(   V \        \	        V4      \        V4      ^ ^ 4      ,          # VP                  '       dO   \        WP                  ,          WP                  ,          WP                  ,          WP                  ,          4      # \        R4      hV P                  f   VP                  f   RpM%V P                  4       VP                  4       ,          p\        V P                  ) VP                  ,          V P                  VP                  ,          ,
          V P                  VP                  ,          ,
          V P                  VP                  ,          ,           V P                  VP                  ,          V P                  VP                  ,          ,           V P                  VP                  ,          ,
          V P                  VP                  ,          ,           V P                  ) VP                  ,          V P                  VP                  ,          ,           V P                  VP                  ,          ,           V P                  VP                  ,          ,           V P                  VP                  ,          V P                  VP                  ,          ,
          V P                  VP                  ,          ,           V P                  VP                  ,          ,           VR7      # )a†  Generic multiplication.

Parameters
==========

q1 : Quaternion or symbol
q2 : Quaternion or symbol

It is important to note that if neither q1 nor q2 is a Quaternion,
this function simply returns q1 * q2.

Returns
=======

Quaternion
    The resultant quaternion after multiplying q1 and q2

Examples
========

>>> from sympy import Quaternion
>>> from sympy import Symbol, S
>>> q1 = Quaternion(1, 2, 3, 4)
>>> q2 = Quaternion(5, 6, 7, 8)
>>> Quaternion._generic_mul(q1, q2)
(-60) + 12*i + 30*j + 24*k
>>> Quaternion._generic_mul(q1, S(2))
2 + 4*i + 6*j + 8*k
>>> x = Symbol('x', real = True)
>>> Quaternion._generic_mul(q1, x)
x + 2*x*i + 3*x*j + 4*x*k

Quaternions over complex fields :

>>> from sympy import I
>>> q3 = Quaternion(3 + 4*I, 2 + 5*I, 0, 7 + 8*I, real_field = False)
>>> Quaternion._generic_mul(q3, 2 + 3*I)
(2 + 3*I)*(3 + 4*I) + (2 + 3*I)*(2 + 5*I)*i + 0*j + (2 + 3*I)*(7 + 8*I)*k

zAOnly commutative expressions can be multiplied with a Quaternion.N©r/   )rÝ   rG   rW   rÞ   r   r   rJ   rS   rT   rU   rV   r+   r]   r/   )rß   rà   r/   s   && r$   r»   ÚQuaternion._generic_mul  sn  € ôV ˜"œj×)Ò)´*¸RÄ×2LÒ2LØ•7ˆNô ˜"œj×)Ò)Ø�}�}ˆ} §§ Ü!¤" R£&¬"¨R«&°!°QÓ7¸"Õ<Ð<Ø×"×"Ð"Ü! "§t¡t¥)¨R·$±$­Y¸¿T¹T½	À2ÏÉÅ9ÓMÐMä Ð!dÓeÐeô ˜"œj×)Ò)Ø�}�}ˆ} §§ ØœJ¤r¨"£v¬r°"«v°q¸!Ó<Õ<Ð<Ø×"×"Ð"Ü! "§t¡t¥)¨R·$±$­Y¸¿T¹T½	À2ÏÉÅ9ÓMÐMä Ð!dÓeÐeð �8‰8Ò §¡Ò 0Ø‰Dà—7‘7“9˜rŸw™w›yÕ(ˆDä˜2Ÿ4™4˜% §¡�* r§t¡t¨B¯D©D¥yÕ0°2·4±4¸¿¹µ9Õ<¸r¿t¹tÀBÇDÁD½yÕHØŸ$™$˜rŸt™t�) b§d¡d¨2¯4©4¥iÕ/°"·$±$°r·t±tµ)Õ;¸b¿d¹dÀ2Ç4Á4½iÕGØŸ4™4˜% §¡�* r§t¡t¨B¯D©D¥yÕ0°2·4±4¸¿¹µ9Õ<¸r¿t¹tÀBÇDÁD½yÕHØŸ$™$˜rŸt™t�) b§d¡d¨2¯4©4¥iÕ/°"·$±$°r·t±tµ)Õ;¸b¿d¹dÀRÇTÁT½kÕIØ#ô	%ð 	%r2   c                ó�   € T p\        VP                  VP                  ) VP                  ) VP                  ) VP
                  R7      # )z(Returns the conjugate of the quaternion.ræ   )rG   rS   rT   rU   rV   r]   ©r^   Úqs   & r$   Ú_eval_conjugateÚQuaternion._eval_conjugateh  s4   € àˆÜ˜!Ÿ#™# §¡˜t a§c¡c T¨A¯C©C¨4°a·g±gÔ>Ð>r2   c                ó  € V P                   fp   T p\        \        VP                  ^,          VP                  ^,          ,           VP
                  ^,          ,           VP                  ^,          ,           4      4      # V P                   # )z#Returns the norm of the quaternion.)r]   r   r   rS   rT   rU   rV   ré   s   & r$   r/   ÚQuaternion.normm  s[   € à�:‰:ÒØˆAô œ §¡ a¥¨!¯#©#¨q­&¥°1·3±3¸µ6Õ!9¸A¿C¹CÀ½FÕ!BÓCÓDÐDà�z‰zÐr2   c                óB   € T pV^VP                  4       ,          ,          # )z.Returns the normalized form of the quaternion.ræ   ré   s   & r$   Ú	normalizeÚQuaternion.normalizew  s   € àˆØ�A�a—f‘f“h•JÕÐr2   c                ó¤   € T pVP                  4       '       g   \        R4      h\        V4      ^VP                  4       ^,          ,          ,          # )z&Returns the inverse of the quaternion.z6Cannot compute inverse for a quaternion with zero norm)r/   r+   r   ré   s   & r$   ÚinverseÚQuaternion.inverse|  s;   € àˆØ�v‰v�xŠxÜÐUÓVÐVÜ˜‹|˜q §¡£¨1¥�}Õ-Ð-r2   c                ó  €  T \        V4      rT^ 8  d   TP                  4       T) rT^8X  d   T# \	        ^^ ^ ^ 4      pT^ 8”  d+   T^,          '       d	   Y2,          pY",          pT^,          pK1  T#   \         d
    \        u # i ; i)ak  Finds the pth power of the quaternion.

Parameters
==========

p : int
    Power to be applied on quaternion.

Returns
=======

Quaternion
    Returns the p-th power of the current quaternion.
    Returns the inverse if p = -1.

Examples
========

>>> from sympy import Quaternion
>>> q = Quaternion(1, 2, 3, 4)
>>> q.pow(4)
668 + (-224)*i + (-336)*j + (-448)*k

)r   r+   ÚNotImplementedró   rG   )r^   rÃ   rê   Úress   &&  r$   rÂ   ÚQuaternion.powƒ  s‰   € ð2	"Øœ ›ˆqð ˆqŒ5Ø—9‘9“;  ˆqà�Œ6ØˆHä˜˜A˜q !Ó$ˆØ�!ŒeØ�1�uŒuØ•�Ø�FˆAØ�!�GŠAàˆ
øô! ô 	"Ü!Ò!ð	"ús   ‚A1 Á1BÂBc                ón  € T p\        VP                  ^,          VP                  ^,          ,           VP                  ^,          ,           4      p\	        VP
                  4      \        V4      ,          p\	        VP
                  4      \        V4      ,          VP                  ,          V,          p\	        VP
                  4      \        V4      ,          VP                  ,          V,          p\	        VP
                  4      \        V4      ,          VP                  ,          V,          p\        W4WV4      # )aK  Returns the exponential of $q$, given by $e^q$.

Returns
=======

Quaternion
    The exponential of the quaternion.

Examples
========

>>> from sympy import Quaternion
>>> q = Quaternion(1, 2, 3, 4)
>>> q.exp()
E*cos(sqrt(29))
+ 2*sqrt(29)*E*sin(sqrt(29))/29*i
+ 3*sqrt(29)*E*sin(sqrt(29))/29*j
+ 4*sqrt(29)*E*sin(sqrt(29))/29*k

)	r   rT   rU   rV   r
   rS   r   r   rG   )r^   rê   Úvector_normrS   rT   rU   rV   s   &      r$   r
   ÚQuaternion.exp°  sÇ   € ð, ˆÜ˜1Ÿ3™3 �6 A§C¡C¨¥F�?¨Q¯S©S°!­VÕ3Ó4ˆÜ�—‘‹H”s˜;Ó'Õ'ˆÜ�—‘‹H”s˜;Ó'Õ'¨!¯#©#Õ-°Õ;ˆÜ�—‘‹H”s˜;Ó'Õ'¨!¯#©#Õ-°Õ;ˆÜ�—‘‹H”s˜;Ó'Õ'¨!¯#©#Õ-°Õ;ˆä˜! Ó%Ð%r2   c                ó$  € T p\        VP                  ^,          VP                  ^,          ,           VP                  ^,          ,           4      pVP	                  4       p\        V4      pVP                  \        VP                  V,          4      ,          V,          pVP                  \        VP                  V,          4      ,          V,          pVP                  \        VP                  V,          4      ,          V,          p\        WEWg4      # )a  Returns the logarithm of the quaternion, given by $\log q$.

Examples
========

>>> from sympy import Quaternion
>>> q = Quaternion(1, 2, 3, 4)
>>> q.log()
log(sqrt(30))
+ 2*sqrt(29)*acos(sqrt(30)/30)/29*i
+ 3*sqrt(29)*acos(sqrt(30)/30)/29*j
+ 4*sqrt(29)*acos(sqrt(30)/30)/29*k

)	r   rT   rU   rV   r/   Úlnr   rS   rG   )r^   rê   rú   Úq_normrS   rT   rU   rV   s   &       r$   r   ÚQuaternion.logÏ  sµ   € ð  ˆÜ˜1Ÿ3™3 �6 A§C¡C¨¥F�?¨Q¯S©S°!­VÕ3Ó4ˆØ—‘“ˆÜˆv‹JˆØ�C‰C”$�q—s‘s˜V•|Ó$Õ$ {Õ2ˆØ�C‰C”$�q—s‘s˜V•|Ó$Õ$ {Õ2ˆØ�C‰C”$�q—s‘s˜V•|Ó$Õ$ {Õ2ˆä˜! Ó%Ð%r2   c                óÈ   € V P                    Uu. uF  q"P                  ! V!  NK  	  ppV P                  pVe   VP                  ! V!  p\        W44       \	        VRV/ # u upi )Nr/   )r\   Úsubsr]   r1   rG   )r^   r\   r#   r.   r/   s   &*   r$   Ú
_eval_subsÚQuaternion._eval_subsé  sZ   € Ø+/¯9ª9Ó5©9 a—F’F˜D”M©9ˆÐ5Ø�z‰zˆØÒØ—9’9˜dÑ#ˆDÜ�HÔ#Ü˜8Ð/¨$Ñ/Ð/ùò 6s   �Ac           	     ó†   € \        V4      p\        V P                   Uu. uF  q3P                  VR7      NK  	  up!  # u upi )a“  Returns the floating point approximations (decimal numbers) of the quaternion.

Returns
=======

Quaternion
    Floating point approximations of quaternion(self)

Examples
========

>>> from sympy import Quaternion
>>> from sympy import sqrt
>>> q = Quaternion(1/sqrt(1), 1/sqrt(2), 1/sqrt(3), 1/sqrt(4))
>>> q.evalf()
1.00000000000000
+ 0.707106781186547*i
+ 0.577350269189626*j
+ 0.500000000000000*k

)r„   )r   rG   r\   Úevalf)r^   ÚprecÚnprecÚargs   &&  r$   Ú_eval_evalfÚQuaternion._eval_evalfñ  s8   € ô, ˜DÓ!ˆÜ¸$¿)º)ÓD¹)°3ŸI™I¨˜IÖ.¹)ÑDÑEÐEùÒDs   Ÿ>c                óœ   € T pVP                  4       w  r4\        P                  W1V,          4      pWRP                  4       V,          ,          # )aÉ  Computes the pth power in the cos-sin form.

Parameters
==========

p : int
    Power to be applied on quaternion.

Returns
=======

Quaternion
    The p-th power in the cos-sin form.

Examples
========

>>> from sympy import Quaternion
>>> q = Quaternion(1, 2, 3, 4)
>>> q.pow_cos_sin(4)
900*cos(4*acos(sqrt(30)/30))
+ 1800*sqrt(29)*sin(4*acos(sqrt(30)/30))/29*i
+ 2700*sqrt(29)*sin(4*acos(sqrt(30)/30))/29*j
+ 3600*sqrt(29)*sin(4*acos(sqrt(30)/30))/29*k

)Úto_axis_anglerG   r‚   r/   )r^   rÃ   rê   Úvrž   rà   s   &&    r$   Úpow_cos_sinÚQuaternion.pow_cos_sin
  s>   € ð< ˆØ—_‘_Ó&‰
ˆÜ×'Ñ'¨¨u­9Ó5ˆØ—V‘V“X˜q•[Õ!Ð!r2   c           	     óÆ   € \        \        V P                  .VO5!  \        V P                  .VO5!  \        V P                  .VO5!  \        V P
                  .VO5!  4      # )aö  Computes integration of quaternion.

Returns
=======

Quaternion
    Integration of the quaternion(self) with the given variable.

Examples
========

Indefinite Integral of quaternion :

>>> from sympy import Quaternion
>>> from sympy.abc import x
>>> q = Quaternion(1, 2, 3, 4)
>>> q.integrate(x)
x + 2*x*i + 3*x*j + 4*x*k

Definite integral of quaternion :

>>> from sympy import Quaternion
>>> from sympy.abc import x
>>> q = Quaternion(1, 2, 3, 4)
>>> q.integrate((x, 1, 5))
4 + 8*i + 12*j + 16*k

)rG   r   rS   rT   rU   rV   rÑ   s   &*r$   r   ÚQuaternion.integrate-  sT   € ô: œ) D§F¡FÐ2¨TÓ2´I¸d¿f¹fÐ4LÀtÓ4LÜ# D§F¡FÐ2¨TÓ2´I¸d¿f¹fÐ4LÀtÓ4LóNð 	Nr2   c                óR  € \        V\        4      '       d&   \        P                  V^ ,          V^,          4      pMVP	                  4       pV\        ^ V ^ ,          V ^,          V ^,          4      ,          \        V4      ,          pVP                  VP                  VP                  3# )a>  Returns the coordinates of the point pin (a 3 tuple) after rotation.

Parameters
==========

pin : tuple
    A 3-element tuple of coordinates of a point which needs to be
    rotated.
r : Quaternion or tuple
    Axis and angle of rotation.

    It's important to note that when r is a tuple, it must be of the form
    (axis, angle)

Returns
=======

tuple
    The coordinates of the point after rotation.

Examples
========

>>> from sympy import Quaternion
>>> from sympy import symbols, trigsimp, cos, sin
>>> x = symbols('x')
>>> q = Quaternion(cos(x/2), 0, 0, sin(x/2))
>>> trigsimp(Quaternion.rotate_point((1, 1, 1), q))
(sqrt(2)*cos(x + pi/4), sqrt(2)*sin(x + pi/4), 1)
>>> (axis, angle) = q.to_axis_angle()
>>> trigsimp(Quaternion.rotate_point((1, 1, 1), (axis, angle)))
(sqrt(2)*cos(x + pi/4), sqrt(2)*sin(x + pi/4), 1)

)	rÝ   r“   rG   r‚   rð   r   rT   rU   rV   )ÚpinÚrrê   Úpouts   &&  r$   Úrotate_pointÚQuaternion.rotate_pointM  s|   € ôH �aœ×Òä×*Ñ*¨1¨Q­4°°1µÓ6‰Að —‘“ˆAØ”:˜a  Q¥¨¨Q­°°QµÓ8Õ8¼9ÀQ»<ÕGˆØ—‘˜Ÿ™ §¡Ð'Ð'r2   c                óÎ  € T pVP                   P                  '       d
   VR,          pVP                  4       p\        ^\	        VP                   4      ,          4      p\        ^VP                   VP                   ,          ,
          4      p\        VP                  V,          4      p\        VP                  V,          4      p\        VP                  V,          4      pWEV3pWr3pV# )a"  Returns the axis and angle of rotation of a quaternion.

Returns
=======

tuple
    Tuple of (axis, angle)

Examples
========

>>> from sympy import Quaternion
>>> q = Quaternion(1, 1, 1, 1)
>>> (axis, angle) = q.to_axis_angle()
>>> axis
(sqrt(3)/3, sqrt(3)/3, sqrt(3)/3)
>>> angle
2*pi/3

rŽ   )	rS   Úis_negativerð   r   r   r   rT   rU   rV   )	r^   rê   rž   r¢   rŸ   r    r¡   r  Úts	   &        r$   r  ÚQuaternion.to_axis_anglez  s§   € ð* ˆØ�3‰3�?�?ˆ?Ø�B•ˆAà�K‰K‹MˆÜ˜œT !§#¡#›Y�Ó'ˆô ��Q—S‘S˜Ÿ™•W•Óˆä�Q—S‘S˜1•WÓˆÜ�Q—S‘S˜1•WÓˆÜ�Q—S‘S˜1•WÓˆà�1ˆIˆØˆJˆàˆr2   c           	     ó0	  € T pVP                  4       R,          pV'       Ed%   WCP                  ^,          VP                  ^,          ,           VP                  ^,          ,
          VP                  ^,          ,
          ,          pWCP                  ^,          VP                  ^,          ,
          VP                  ^,          ,           VP                  ^,          ,
          ,          pWCP                  ^,          VP                  ^,          ,
          VP                  ^,          ,
          VP                  ^,          ,           ,          pMÀ^^V,          VP                  ^,          VP                  ^,          ,           ,          ,
          p^^V,          VP                  ^,          VP                  ^,          ,           ,          ,
          p^^V,          VP                  ^,          VP                  ^,          ,           ,          ,
          p^V,          VP                  VP                  ,          VP                  VP                  ,          ,
          ,          p^V,          VP                  VP                  ,          VP                  VP                  ,          ,           ,          p	^V,          VP                  VP                  ,          VP                  VP                  ,          ,           ,          p
^V,          VP                  VP                  ,          VP                  VP                  ,          ,
          ,          p^V,          VP                  VP                  ,          VP                  VP                  ,          ,
          ,          p^V,          VP                  VP                  ,          VP                  VP                  ,          ,           ,          pV'       g   \        WXV	.W¦V.WÍV..4      # Vw  rïpWîV,          ,
          Wø,          ,
          VV	,          ,
          pWþV
,          ,
          Wö,          ,
          VV,          ,
          pVWì,          ,
          Wý,          ,
          VV,          ,
          p^ ;p;pp^p\        WXV	V.W¦VV.WÍVV.VVVV..4      # )aò  Returns the equivalent rotation transformation matrix of the quaternion
which represents rotation about the origin if ``v`` is not passed.

Parameters
==========

v : tuple or None
    Default value: None
homogeneous : bool
    When True, gives an expression that may be more efficient for
    symbolic calculations but less so for direct evaluation. Both
    formulas are mathematically equivalent.
    Default value: True

Returns
=======

tuple
    Returns the equivalent rotation transformation matrix of the quaternion
    which represents rotation about the origin if v is not passed.

Examples
========

>>> from sympy import Quaternion
>>> from sympy import symbols, trigsimp, cos, sin
>>> x = symbols('x')
>>> q = Quaternion(cos(x/2), 0, 0, sin(x/2))
>>> trigsimp(q.to_rotation_matrix())
Matrix([
[cos(x), -sin(x), 0],
[sin(x),  cos(x), 0],
[     0,       0, 1]])

Generates a 4x4 transformation matrix (used for rotation about a point
other than the origin) if the point(v) is passed as an argument.
éþÿÿÿ)r/   rS   rT   rU   rV   rr   )r^   r  Úhomogeneousrê   r¢   Úm00Úm11Úm22Úm01Úm02Úm10Úm12Úm20Úm21rŸ   r    r¡   Úm03Úm13Úm23Úm30Úm31Úm32Úm33s   &&&                     r$   Úto_rotation_matrixÚQuaternion.to_rotation_matrix¢  s  € ðN ˆØ�F‰F‹H�b�Lˆ÷ ˆ;Ø—S‘S˜!•V˜aŸc™c 1�f•_ q§s¡s¨A¥vÕ-°·±°QµÕ6Õ7ˆCØ—S‘S˜!•V˜aŸc™c 1�f•_ q§s¡s¨A¥vÕ-°·±°QµÕ6Õ7ˆCØ—S‘S˜!•V˜aŸc™c 1�f•_ q§s¡s¨A¥vÕ-°·±°QµÕ6Õ7‰Cà�a˜•c˜1Ÿ3™3 �6 A§C¡C¨¥F�?Õ+Õ+ˆCØ�a˜•c˜1Ÿ3™3 �6 A§C¡C¨¥F�?Õ+Õ+ˆCØ�a˜•c˜1Ÿ3™3 �6 A§C¡C¨¥F�?Õ+Õ+ˆCà��c�1—3‘3�q—s‘s•7˜QŸS™S §¡�WÕ$Õ%ˆØ��c�1—3‘3�q—s‘s•7˜QŸS™S §¡�WÕ$Õ%ˆà��c�1—3‘3�q—s‘s•7˜QŸS™S §¡�WÕ$Õ%ˆØ��c�1—3‘3�q—s‘s•7˜QŸS™S §¡�WÕ$Õ%ˆà��c�1—3‘3�q—s‘s•7˜QŸS™S §¡�WÕ$Õ%ˆØ��c�1—3‘3�q—s‘s•7˜QŸS™S §¡�WÕ$Õ%ˆçÜ˜C c˜?¨S°s¨O¸cÈ¸_ÐMÓNÐNð ‰IˆQ�1à˜•e•)˜a�eÕ# a¨¥eÕ+ˆCØ˜•e•)˜a�eÕ# a¨¥eÕ+ˆCØ�a•e•)˜a�eÕ# a¨¥eÕ+ˆCØÐˆCÐ�#˜ØˆCä˜C c¨3Ð/°#¸CÀÐ1EØ S¨#Ð.°°c¸3ÀÐ0DðFó Gð Gr2   c                ó   € V P                   # )a  Returns scalar part($\mathbf{S}(q)$) of the quaternion q.

Explanation
===========

Given a quaternion $q = a + bi + cj + dk$, returns $\mathbf{S}(q) = a$.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(4, 8, 13, 12)
>>> q.scalar_part()
4

)rS   rb   s   &r$   Úscalar_partÚQuaternion.scalar_partî  s   € ð$ �v‰vˆr2   c                óZ   € \        ^ V P                  V P                  V P                  4      # )a‹  
Returns $\mathbf{V}(q)$, the vector part of the quaternion $q$.

Explanation
===========

Given a quaternion $q = a + bi + cj + dk$, returns $\mathbf{V}(q) = bi + cj + dk$.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(1, 1, 1, 1)
>>> q.vector_part()
0 + 1*i + 1*j + 1*k

>>> q = Quaternion(4, 8, 13, 12)
>>> q.vector_part()
0 + 8*i + 13*j + 12*k

)rG   rT   rU   rV   rb   s   &r$   Úvector_partÚQuaternion.vector_part  s!   € ô. ˜!˜TŸV™V T§V¡V¨T¯V©VÓ4Ð4r2   c                ó–   € V P                  4       P                  4       p\        ^ VP                  VP                  VP
                  4      # )a  
Returns $\mathbf{Ax}(q)$, the axis of the quaternion $q$.

Explanation
===========

Given a quaternion $q = a + bi + cj + dk$, returns $\mathbf{Ax}(q)$  i.e., the versor of the vector part of that quaternion
equal to $\mathbf{U}[\mathbf{V}(q)]$.
The axis is always an imaginary unit with square equal to $-1 + 0i + 0j + 0k$.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(1, 1, 1, 1)
>>> q.axis()
0 + sqrt(3)/3*i + sqrt(3)/3*j + sqrt(3)/3*k

See Also
========

vector_part

)r5  rð   rG   rT   rU   rV   )r^   Úaxiss   & r$   r8  ÚQuaternion.axis  s8   € ð2 ×ÑÓ!×+Ñ+Ó-ˆä˜!˜TŸV™V T§V¡V¨T¯V©VÓ4Ð4r2   c                ó.   € V P                   P                  # )a‚  
Returns true if the quaternion is pure, false if the quaternion is not pure
or returns none if it is unknown.

Explanation
===========

A pure quaternion (also a vector quaternion) is a quaternion with scalar
part equal to 0.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(0, 8, 13, 12)
>>> q.is_pure()
True

See Also
========
scalar_part

)rS   Úis_zerorb   s   &r$   Úis_pureÚQuaternion.is_pure8  s   € ð2 �v‰v�~‰~Ðr2   c                ó6   € V P                  4       P                  # )aâ  
Returns true if the quaternion is a zero quaternion or false if it is not a zero quaternion
and None if the value is unknown.

Explanation
===========

A zero quaternion is a quaternion with both scalar part and
vector part equal to 0.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(1, 0, 0, 0)
>>> q.is_zero_quaternion()
False

>>> q = Quaternion(0, 0, 0, 0)
>>> q.is_zero_quaternion()
True

See Also
========
scalar_part
vector_part

)r/   r;  rb   s   &r$   r�   ÚQuaternion.is_zero_quaternionS  s   € ð< �y‰y‹{×"Ñ"Ð"r2   c                ó|   € ^\        V P                  4       P                  4       V P                  4       4      ,          # )aÇ  
Returns the angle of the quaternion measured in the real-axis plane.

Explanation
===========

Given a quaternion $q = a + bi + cj + dk$ where $a$, $b$, $c$ and $d$
are real numbers, returns the angle of the quaternion given by

.. math::
    \theta := 2 \operatorname{atan_2}\left(\sqrt{b^2 + c^2 + d^2}, {a}\right)

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(1, 4, 4, 4)
>>> q.angle()
2*atan(4*sqrt(3))

)r   r5  r/   r2  rb   s   &r$   rž   ÚQuaternion.angles  s1   € ð. ”5˜×)Ñ)Ó+×0Ñ0Ó2°D×4DÑ4DÓ4FÓGÕGÐGr2   c                óN  € V P                  4       '       g   VP                  4       '       d   \        R4      h\        V P                  4       VP                  4       ,
          P                  4       V P                  4       VP                  4       ,           P                  4       .4      # )as  
Returns True if the transformation arcs represented by the input quaternions happen in the same plane.

Explanation
===========

Two quaternions are said to be coplanar (in this arc sense) when their axes are parallel.
The plane of a quaternion is the one normal to its axis.

Parameters
==========

other : a Quaternion

Returns
=======

True : if the planes of the two quaternions are the same, apart from its orientation/sign.
False : if the planes of the two quaternions are not the same, apart from its orientation/sign.
None : if plane of either of the quaternion is unknown.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q1 = Quaternion(1, 4, 4, 4)
>>> q2 = Quaternion(3, 8, 8, 8)
>>> Quaternion.arc_coplanar(q1, q2)
True

>>> q1 = Quaternion(2, 8, 13, 12)
>>> Quaternion.arc_coplanar(q1, q2)
False

See Also
========

vector_coplanar
is_pure

z)Neither of the given quaternions can be 0)r�   r+   r   r8  r­   s   &&r$   Úarc_coplanarÚQuaternion.arc_coplanar�  sv   € ðT ×#Ñ#×%Ò%¨5×+CÑ+C×+EÒ+EÜÐHÓIÐIä˜$Ÿ)™)›+¨¯
©
«Õ4×HÑHÓJÈTÏYÉYË[Ð[`×[eÑ[eÓ[gÕMg×L{ÑL{ÓL}Ð~ÓÐr2   c                óè  € \        VP                  4       4      '       g?   \        VP                  4       4      '       g    \        VP                  4       4      '       d   \        R4      h\        VP                  VP
                  VP                  .VP                  VP
                  VP                  .VP                  VP
                  VP                  ..4      P                  4       pVP                  # )aò  
Returns True if the axis of the pure quaternions seen as 3D vectors
``q1``, ``q2``, and ``q3`` are coplanar.

Explanation
===========

Three pure quaternions are vector coplanar if the quaternions seen as 3D vectors are coplanar.

Parameters
==========

q1
    A pure Quaternion.
q2
    A pure Quaternion.
q3
    A pure Quaternion.

Returns
=======

True : if the axis of the pure quaternions seen as 3D vectors
q1, q2, and q3 are coplanar.
False : if the axis of the pure quaternions seen as 3D vectors
q1, q2, and q3 are not coplanar.
None : if the axis of the pure quaternions seen as 3D vectors
q1, q2, and q3 are coplanar is unknown.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q1 = Quaternion(0, 4, 4, 4)
>>> q2 = Quaternion(0, 8, 8, 8)
>>> q3 = Quaternion(0, 24, 24, 24)
>>> Quaternion.vector_coplanar(q1, q2, q3)
True

>>> q1 = Quaternion(0, 8, 16, 8)
>>> q2 = Quaternion(0, 8, 3, 12)
>>> Quaternion.vector_coplanar(q1, q2, q3)
False

See Also
========

axis
is_pure

ú"The given quaternions must be pure)	r   r<  r+   rr   rT   rU   rV   r¥   r;  )rR   rß   rà   Úq3r¦   s   &&&& r$   Úvector_coplanarÚQuaternion.vector_coplanar¼  sŸ   € ôl �R—Z‘Z“\×"Ò"¤i°·
±
³×&=Ò&=ÄÈ2Ï:É:Ë<×AXÒAXÜÐAÓBÐBä�R—T‘T˜2Ÿ4™4 §¡Ð&¨¯©¨r¯t©t°R·T±TÐ(:¸R¿T¹TÀ2Ç4Á4ÈÏÉÐ<NÐOÓP×TÑTÓVˆØ�y‰yÐr2   c                óÚ   € \        V P                  4       4      '       g    \        VP                  4       4      '       d   \        R4      hW,          W,          ,
          P                  4       # )aú  
Returns True if the two pure quaternions seen as 3D vectors are parallel.

Explanation
===========

Two pure quaternions are called parallel when their vector product is commutative which
implies that the quaternions seen as 3D vectors have same direction.

Parameters
==========

other : a Quaternion

Returns
=======

True : if the two pure quaternions seen as 3D vectors are parallel.
False : if the two pure quaternions seen as 3D vectors are not parallel.
None : if the two pure quaternions seen as 3D vectors are parallel is unknown.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(0, 4, 4, 4)
>>> q1 = Quaternion(0, 8, 8, 8)
>>> q.parallel(q1)
True

>>> q1 = Quaternion(0, 8, 13, 12)
>>> q.parallel(q1)
False

z%The provided quaternions must be pure©r   r<  r+   r�   r­   s   &&r$   ÚparallelÚQuaternion.parallelø  sJ   € ôJ �T—\‘\“^×$Ò$¬	°%·-±-³/×(BÒ(BÜÐDÓEÐEà•
˜U�ZÕ'×;Ñ;Ó=Ð=r2   c                óÚ   € \        V P                  4       4      '       g    \        VP                  4       4      '       d   \        R4      hW,          W,          ,           P                  4       # )a¼  
Returns the orthogonality of two quaternions.

Explanation
===========

Two pure quaternions are called orthogonal when their product is anti-commutative.

Parameters
==========

other : a Quaternion

Returns
=======

True : if the two pure quaternions seen as 3D vectors are orthogonal.
False : if the two pure quaternions seen as 3D vectors are not orthogonal.
None : if the two pure quaternions seen as 3D vectors are orthogonal is unknown.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(0, 4, 4, 4)
>>> q1 = Quaternion(0, 8, 8, 8)
>>> q.orthogonal(q1)
False

>>> q1 = Quaternion(0, 2, 2, 0)
>>> q = Quaternion(0, 2, -2, 0)
>>> q.orthogonal(q1)
True

rF  rK  r­   s   &&r$   Ú
orthogonalÚQuaternion.orthogonal"  sJ   € ôJ �T—\‘\“^×$Ò$¬	°%·-±-³/×(BÒ(BÜÐAÓBÐBà•
˜U�ZÕ'×;Ñ;Ó=Ð=r2   c                óL   € V P                  4       V P                  4       ,          # )aú  
Returns the index vector of the quaternion.

Explanation
===========

The index vector is given by $\mathbf{T}(q)$, the norm (or magnitude) of
the quaternion $q$, multiplied by $\mathbf{Ax}(q)$, the axis of $q$.

Returns
=======

Quaternion: representing index vector of the provided quaternion.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(2, 4, 2, 4)
>>> q.index_vector()
0 + 4*sqrt(10)/3*i + 2*sqrt(10)/3*j + 4*sqrt(10)/3*k

See Also
========

axis
norm

)r/   r8  rb   s   &r$   Úindex_vectorÚQuaternion.index_vectorL  s   € ð> �y‰y‹{˜TŸY™Y›[Õ(Ð(r2   c                ó4   € \        V P                  4       4      # )a  
Returns the natural logarithm of the norm(magnitude) of the quaternion.

Examples
========

>>> from sympy.algebras.quaternion import Quaternion
>>> q = Quaternion(2, 4, 2, 4)
>>> q.mensor()
log(2*sqrt(10))
>>> q.norm()
2*sqrt(10)

See Also
========

norm

)rý   r/   rb   s   &r$   ÚmensorÚQuaternion.mensorm  s   € ô* �$—)‘)“+‹Ðr2   )r]   )r   r   r   r   TN)F)TF)NT)DÚ__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú_op_priorityrJ   rO   rQ   ÚpropertyrS   rT   rU   rV   rW   rs   rv   rz   Úclassmethodr~   r‹   r™   r‚   r¨   r¯   r³   r·   r¼   r¿   rÄ   rÇ   rË   rÎ   rÒ   rØ   r¬   rã   Ústaticmethodr»   rë   r/   rð   ró   rÂ   r
   r   r  r	  r  r   r  r  r/  r2  r5  r8  r<  r�   rž   rC  rH  rL  rO  rR  rU  Ú__static_attributes__Ú__classdictcell__Ú__classcell__)rY   Ú__classdict__s   @@r$   rG   rG   :   s#  ù‡ € ñ/ð` €Là€N÷ò"ðH ñó ðð ñó ðð ñó ðð ñó ðð ñ ó ð ð ñ/4ó ð/4ðb ñ44ó ð44ôl/%ðb ñ()ó ð()ðT ñ=*ó ð=*ô~L!ð\ ñ(ó ð(ðT ñ)&ó ð)&òVòò"ò8ò8òò>ò)ò)ò%òLò4"òl'8ðR ñI%ó ðI%òV?ò
ò ò
.ò+òZ&ò>&ò40òFò2!"òFNð@ ñ*(ó ð*(òX&ôPJGòXò(5ò25ò:ò6#ò@Hò4-@ð^ ñ9ó ð9òv(>òT(>òT)÷Bò r2   rG   N)-Úsympy.core.numbersr   Úsympy.core.singletonr   Úsympy.core.relationalr   Ú$sympy.functions.elementary.complexesr   r   r   r	   Ú&sympy.functions.elementary.exponentialr
   r   rý   Ú(sympy.functions.elementary.miscellaneousr   Ú(sympy.functions.elementary.trigonometricr   r   r   r   r   Úsympy.simplify.trigsimpr   Úsympy.integrals.integralsr   Úsympy.matrices.denser   rr   Úsympy.core.sympifyr   r   Úsympy.core.exprr   Úsympy.core.logicr   r   Úsympy.utilities.miscr   Úmpmath.libmp.libmpfr   r1   rE   rG   r)   r2   r$   Ú<module>rs     sS   ðÝ 'Ý "Ý 'ß JÓ Jß CÝ 9ß HÑ Hß ?Ý ,Ý /Ý =ß 0Ý  ß 0Ý 'å +ò=òô6H�ö Hr2   