Ë
    :vžj‹  ã                   ó<   — d dl ZddlmZmZ ddlmZ  G d„ d«      Zy)é    Né   )ÚcachingÚutil)Útransformationsc                   óZ  — e Zd ZdZddej
                  dz  fd„Zd„ Zed„ «       Z	ed„ «       Z
e
j                  d„ «       Z
ej                  d	„ «       Zej                  d
„ «       Zej                  d„ «       Zd„ Zd„ Zd„ Zd„ Zd„ Zej                  d„ «       Zd„ Zej                  d„ «       Zy)Ú	Transformz¾
    Class for caching metadata associated with 4x4 transformations.

    The transformation matrix is used to define relevant properties
    for the voxels, including pitch and origin.
    NÚ	datastorec                 óæ  — t        j                  |t         j                  ¬«      }|j                  dk7  st        j                  |ddd…f   g d¢«      st        d«      ‚|€t        j                  «       | _        n9t        |t        j                  «      r|| _        nt        t        |«      › d�«      ‚|| j                  d<   t        j                  | j                  j                  ¬	«      | _        y)
a  
        Initialize with a transform.

        Parameters
        -----------
        matrix : (4, 4) float
          Homogeneous transformation matrix
        datastore
          If passed store the actual values in a reference to
          another datastore.
        ©Údtype©é   r   é   N)r   r   r   é   zmatrix is invalid!z != caching.DataStoreÚtransform_matrix)Úid_function)ÚnpÚ
asanyarrayÚfloat64ÚshapeÚallcloseÚ
ValueErrorr   Ú	DataStoreÚ_dataÚ
isinstanceÚtypeÚCacheÚ__hash__Ú_cache)ÚselfÚmatrixr	   s      úi/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/trimesh/voxel/transforms.pyÚ__init__zTransform.__init__   sµ   € ô —‘˜v¬R¯Z©ZÔ8ˆØ�<‰<˜6Ò!¬¯©°V¸Aºq¸D±\Â<Ô)PÜÐ1Ó2Ð2ð ÐÜ ×*Ñ*Ó,ˆD�JÜ˜	¤7×#4Ñ#4Ô5Ø"ˆD�Jä¤ Y£Ð0Ð0EÐFÓGÐGà)/ˆ�
‰
Ð%Ñ&ä—m‘m°·
±
×0CÑ0CÔDˆ�ó    c                 ó6   — | j                   j                  «       S )z¥
        Get the hash of the current transformation matrix.

        Returns
        ------------
        hash : str
          Hash of transformation matrix
        )r   r   ©r    s    r"   r   zTransform.__hash__+   s   € ð �z‰z×"Ñ"Ó$Ð$r$   c                 ó.   — | j                   d   dd…df   S )z¤
        Get the translation component of the matrix

        Returns
        ------------
        translation : (3,) float
          Cartesian translation
        r   Nr   ©r   r&   s    r"   ÚtranslationzTransform.translation6   s!   € ð �z‰zÐ,Ñ-¨b¨q¨b°!¨eÑ4Ð4r$   c                 ó    — | j                   d   S )z¡
        Get the homogeneous transformation matrix.

        Returns
        -------------
        matrix : (4, 4) float
          Transformation matrix
        r   r(   r&   s    r"   r!   zTransform.matrixB   s   € ð �z‰zÐ,Ñ-Ð-r$   c                 ó    — t        j                  |t         j                  ¬«      }|j                  dk7  rt	        d«      ‚|| j
                  d<   y)z¤
        Set the homogeneous transformation matrix.

        Parameters
        -------------
        matrix : (4, 4) float
          Transformation matrix
        r   r   zmatrix must be (4, 4)!r   N)r   r   r   r   r   r   )r    Úvaluess     r"   r!   zTransform.matrixN   s?   € ô —‘˜v¬R¯Z©ZÔ8ˆØ�<‰<˜6Ò!ÜÐ5Ó6Ð6Ø)/ˆ�
‰
Ð%Ò&r$   c                 óè   — | j                   }t        j                  |dd…dd…f   «      }t        j                  |dd…dd…f   |t        j                  d«      z  |dz  dz   «      st        d«      ‚|S )z®
        Get the scale factor of the current transformation.

        Returns
        -------------
        scale : (3,) float
          Scale factor from the matrix
        Nr   ç�íµ ÷Æ°>ç:Œ0âŽyE>z&transform features a shear or rotation)r!   r   Údiagr   ÚeyeÚRuntimeError)r    r!   Úscales      r"   r3   zTransform.scale]   sr   € ð —‘ˆä—‘˜˜r ˜r 2 A 2˜v™Ó'ˆÜ�{‰{˜6 " 1 " b q b &™>¨5´2·6±6¸!³9Ñ+<¸eÀd¹lÈTÑ>QÔRÜÐGÓHÐHØˆr$   c           	      óÆ   — | j                   }t        j                  |d   |dd  t        j                  t        j
                  |«      «      dz  dz   «      st        d«      ‚|S )Nr   r   r.   r/   z&transform features non-uniform scaling)r3   r   r   r   ÚmaxÚabsr2   ©r    r3   s     r"   ÚpitchzTransform.pitcho   sR   € à—
‘
ˆÜ�}‰}˜U 1™X u¨Q¨R y´"·&±&¼¿¹À»Ó2GÈ$Ñ2NÐQUÑ2UÔVÜÐGÓHÐHØˆr$   c                 ól   — t         j                  j                  | j                  d   dd…dd…f   «      S )z"Volume of a transformed unit cube.r   Nr   )r   ÚlinalgÚdetr   r&   s    r"   Úunit_volumezTransform.unit_volumev   s2   € ô �y‰y�}‰}˜TŸZ™ZÐ(:Ñ;¸B¸Q¸BÀÀÀ¸FÑCÓDÐDr$   c                 óP   — t        j                  || j                  «      | _        | S )ú.Mutate the transform in-place and return self.)r   Úmatmulr!   )r    r!   s     r"   Úapply_transformzTransform.apply_transform{   s   € ä—i‘i ¨¯©Ó4ˆŒØˆr$   c                 ó<   — | j                   dd…dfxx   |z  cc<   | S ©r>   Nr   ©r!   )r    r)   s     r"   Úapply_translationzTransform.apply_translation€   s#   € à�‰�B�Q�B˜�EÓ˜kÑ)ÓØˆr$   c                 ó6   — | j                   ddxxx |z  ccc | S rB   rC   r7   s     r"   Úapply_scalezTransform.apply_scale…   s   € à�‰�B�Q‹˜5Ñ ‹Øˆr$   c                 óÌ   — | j                   r|j                  «       S t        j                  |j	                  dd«      | j
                  «      j	                  |j                  «      S )a  
        Apply the transformation to points (not in-place).

        Parameters
        ----------
        points: (n, 3) float
          Points in cartesian space

        Returns
        ----------
        transformed : (n, 3) float
          Points transformed by matrix
        éÿÿÿÿr   )Úis_identityÚcopyÚtrÚtransform_pointsÚreshaper!   r   ©r    Úpointss     r"   rL   zTransform.transform_pointsŠ   sO   € ð ×ÒØ—;‘;“=Ð Ü×"Ñ" 6§>¡>°"°aÓ#8¸$¿+¹+ÓF×NÑNØ�L‰Ló
ð 	
r$   c                 ó°   — | j                   r|S t        j                  |j                  dd«      | j                  «      j                  |j
                  «      S )z:Apply the inverse transformation to points (not in-place).rH   r   )rI   rK   rL   rM   Úinverse_matrixr   rN   s     r"   Úinverse_transform_pointsz"Transform.inverse_transform_pointsž   sH   € à×ÒØˆMÜ×"Ñ" 6§>¡>°"°aÓ#8¸$×:MÑ:MÓN×VÑVØ�L‰Ló
ð 	
r$   c                 óz   — t         j                  j                  | j                  «      }d|j                  _        |S )NF)r   r:   Úinvr!   ÚflagsÚ	writeable)r    rT   s     r"   rQ   zTransform.inverse_matrix¦   s)   € ä�i‰i�m‰m˜DŸK™KÓ(ˆØ#ˆ�	‰	ÔØˆ
r$   c                 ó.   — t        | j                  ¬«      S )NrC   )r   r!   r&   s    r"   rJ   zTransform.copy¬   s   € Ü §¡Ô,Ð,r$   c                 ój   — t        j                  | j                  t        j                  d«      d«      S )zO
        Flags this transformation being sufficiently close to eye(4).
        r   r/   )r   r   r!   r   r1   r&   s    r"   rI   zTransform.is_identity¯   s#   € ô
 �}‰}˜TŸ[™[¬"¯&©&°«)°TÓ:Ð:r$   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r#   r   Úpropertyr)   r!   ÚsetterÚcache_decoratorr3   r8   r<   r@   rD   rF   rL   rR   rQ   rJ   rI   © r$   r"   r   r      s  „ ññE¨'×*;Ñ*;¸dÑ*Bó Eò8	%ð ñ	5ó ð	5ð ñ	.ó ð	.ð ‡]�]ñ0ó ð0ð ×Ññó ðð" ×Ññó ðð ×ÑñEó ðEòò
ò
ò

ò(
ð ×Ññó ðò
-ð ×Ññ;ó ñ;r$   r   )Únumpyr   Ú r   r   r   rK   r   r`   r$   r"   Ú<module>rc      s   ðÛ ç Ý $÷m;ò m;r$   