Ë
    :vžj  ã                   ó8  — d Z ddlZddlmZmZ ddlmZ ddlm	Z	m
Z
 dde	de
fd	„Zdde
fd
„Zdde
fd„Z G d„ d«      Z	 ej                   ej                  _         ej                   ej                  _         ej                   ej                  _         y# e$ r Y yw xY w)zG
permutate.py
-------------

Randomly deform meshes in different ways.
é    Né   )ÚtransformationsÚutil)Ú	triangles)ÚNumberÚSeedÚtranslation_scaleÚseedc           	      ó^  — t        j                  |«      }t        j                  ||¬«      }|j	                  | j
                  «      j                  d«      }t        j                  ||«      }t        j                  | d«      } |di t        j                  |j                  d«      «      ¤Ž}|S )aâ  
    Return a permutated variant of a mesh by randomly reordering faces
    and rotatating + translating a mesh by a random matrix.

    Parameters
    ----------
    mesh : trimesh.Trimesh
      Mesh, will not be altered by this function
    seed : None or int
      Seed for deterministic results, otherwise OS entropy.

    Returns
    ----------
    permutated : trimesh.Trimesh
      Mesh with same faces as input mesh but reordered
      and rigidly transformed in space.
    )Ú	translater
   )éÿÿÿÿé   ÚTrimesh)r   r   r   © )r   Úrandom_generatorr   Úrandom_rotation_matrixÚpermutationr   ÚreshapeÚtransform_pointsÚ
type_namedÚtriangles_moduleÚ	to_kwargs)Úmeshr	   r
   ÚrandomÚmatrixr   Ú	mesh_typeÚ
permutateds           úb/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/trimesh/permutate.pyÚ	transformr      s˜   € ô( ×"Ñ" 4Ó(€FÜ×3Ñ3Ø#¨&ô€Fð
 ×"Ñ" 4§>¡>Ó2×:Ñ:¸7ÓC€Iä×0Ñ0°¸FÓC€Iô —‘  iÓ0€IáÑWÔ-×7Ñ7¸	×8IÑ8IÈ*Ó8UÓVÑW€JàÐó    c                 ó€  — |€| j                   dz  }t        j                  |«      }|j                  | j                  j
                  «      dz
  |z  }| j                  j                  «       |z   }|j                  || j                     «      }t        j                  | d«      } |di t        j                  |«      ¤Ž}|S )a  
    Add gaussian noise to every vertex of a mesh, making
    no effort to maintain topology or sanity.

    Parameters
    ----------
    mesh : trimesh.Trimesh
      Input geometry, will not be altered
    magnitude : float
      What is the maximum distance per axis we can displace a vertex.
      If None, value defaults to (mesh.scale / 100.0)
    seed : None or int
      Seed for deterministic results, otherwise OS entropy.

    Returns
    ----------
    permutated : trimesh.Trimesh
      Input mesh with noise applied
    g      Y@g      à?r   r   )Úscaler   r   r   ÚverticesÚshapeÚcopyr   Úfacesr   r   r   )	r   Ú	magnituder
   r   ÚoffsetÚvertices_noiser   r   r   s	            r   Únoiser*   5   s«   € ð( ÐØ—J‘J Ñ&ˆ	ä×"Ñ" 4Ó(€FØ�m‰m˜DŸM™M×/Ñ/Ó0°3Ñ6¸)ÑC€FØ—]‘]×'Ñ'Ó)¨FÑ2€Nð ×"Ñ" >°$·*±*Ñ#=Ó>€Iä—‘  iÓ0€IÙÑCÔ-×7Ñ7¸	ÓBÑC€JàÐr    c           
      óP  — t        j                  |«      }|j                  | j                  j                  «      dz   }||j                  d¬«      j                  d«      z  }|j                  d«      | j                  z  j                  d¬«      }t        j                  t        |«      «      t        | j                  «      z   }t        j                  | j                  |f«      }t        j                  t        j                  | j                  dd…ddgf   |f«      t        j                  | j                  dd…ddgf   |f«      t        j                  | j                  dd…ddgf   |f«      f«      }|j                  |«      }t        j                  | d	«      } |||¬
«      }	|	S )aã  
    Subdivide each face of a mesh into three faces with the new vertex
    randomly placed inside the old face.

    This produces a mesh with exactly the same surface area and volume
    but with different tessellation.

    Parameters
    ------------
    mesh : trimesh.Trimesh
      Input geometry
    seed : None or int
      Seed for deterministic results, otherwise OS entropy.

    Returns
    ----------
    permutated : trimesh.Trimesh
      Mesh with remeshed facets
    gš™™™™™©?r   )Úaxis)r   r   )r   r   r   Nr   é   r   )r#   r&   )r   r   r   r&   r$   Úsumr   r   ÚnpÚarangeÚlenr#   ÚvstackÚcolumn_stackr   r   )
r   r
   r   ÚbarycentricÚvertex_faceÚvertex_face_idr#   r&   r   r   s
             r   Útessellationr7   Y   sc  € ô( ×"Ñ" 4Ó(€Fð —-‘- §
¡
× 0Ñ 0Ó1°DÑ8€KØ�;—?‘?¨�?Ó*×2Ñ2°7Ó;Ñ;€Kð ×&Ñ& zÓ2°T·^±^ÑC×HÑHÈaÐHÓP€KÜ—Y‘Yœs ;Ó/Ó0´3°t·}±}Ó3EÑE€Nô �y‰y˜$Ÿ-™-¨Ð5Ó6€Hä�I‰Iä�O‰O˜TŸZ™Zª¨A¨q¨6¨	Ñ2°NÐCÓDÜ�O‰O˜TŸZ™Zª¨A¨q¨6¨	Ñ2°NÐCÓDÜ�O‰O˜TŸZ™Zª¨A¨q¨6¨	Ñ2°NÐCÓDð	
ó€Eð ×Ñ˜uÓ%€Eä—‘  iÓ0€IÙ H°EÔ:€JØÐr    c                   ó<   — e Zd Zd„ Zddefd„Zddefd„Zd	defd„Zy)
Ú
Permutatorc                 ó   — || _         y)zL
        A convenience object to get permutated versions of a mesh.
        N)Ú_mesh)Úselfr   s     r   Ú__init__zPermutator.__init__‹   s   € ð ˆ�
r    Nr
   c                 ó2   — t        | j                  ||¬«      S )N)r	   r
   )r   r;   )r<   r	   r
   s      r   r   zPermutator.transform‘   s   € Ü˜Ÿ™Ð7HÈtÔTÐTr    c                 ó2   — t        | j                  ||¬«      S ©N)r
   )r*   r;   )r<   r'   r
   s      r   r*   zPermutator.noise”   s   € Ü�T—Z‘Z °Ô6Ð6r    c                 ó0   — t        | j                  |¬«      S r@   )r7   r;   )r<   r
   s     r   r7   zPermutator.tessellation—   s   € Ü˜DŸJ™J¨TÔ2Ð2r    )iè  N©NN©N)Ú__name__Ú
__module__Ú__qualname__r=   r   r   r*   r7   r   r    r   r9   r9   Š   s-   „ òñU°dó Uñ7¨$ó 7ñ3 ô 3r    r9   )g     @�@NrB   rC   )Ú__doc__Únumpyr/   Ú r   r   r   r   Útypedr   r   r   r*   r7   r9   ÚAttributeErrorr   r    r   Ú<module>rL      s¡   ðñó ç #Ý +ß ñ# vð #¸dó #ñL! dó !ñH.˜Tó .÷b3ñ 3ð"	à$Ÿ}™}€J×ÑÔØ#,×#4Ñ#4€J×ÑÔ Ø&2×&:Ñ&:€J×ÑÕ#øØò 	áð	ús   ¿AB ÂBÂB