
    Mi                     *   S r SSKrSSKJrJr  SSKJr  SSKJ	r	  SS\	4S jjr
SS	 jrS
 r " S S5      r \R                   \R                  l         \
R                   \R                  l         \R                   \R                  l         g! \ a     gf = f)zG
permutate.py
-------------

Randomly deform meshes in different ways.
    N   )transformationsutil)	triangles)Numbertranslation_scalec           	      N   [         R                  " US9n[        R                  R	                  U R
                  5      R                  S5      n[         R                  " X25      n[        R                  " U S5      nU" S0 [        R                  " UR                  S5      5      D6nU$ )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

Returns
----------
permutated : trimesh.Trimesh
  Mesh with same faces as input mesh but reordered
  and rigidly transformed in space.
)	translate)   Trimesh)r   r   r    )r   random_rotation_matrixnprandompermutationr   reshapetransform_pointsr   
type_namedtriangles_module	to_kwargs)meshr   matrixr   	mesh_type
permutateds         k/var/www/eduai.edurigo.com/storigo/production/storigo_env/lib/python3.13/site-packages/trimesh/permutate.py	transformr      s    " 33>OPF 		%%dnn5==gFI00CI i0IW-77	8I8I*8UVWJ    c                    Uc  U R                   S-  n[        R                  R                  U R                  R                  5      S-
  U-  nU R                  R                  5       U-   n[        R                  R                  X0R                     5      n[        R                  " U S5      nU" S0 [        R                  " U5      D6nU$ )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)

Returns
----------
permutated : trimesh.Trimesh
  Input mesh with noise applied
g      Y@g      ?r   r   )scaler   r   verticesshapecopyr   facesr   r   r   r   )r   	magnituder   vertices_noiser   r   r   s          r   noiser'   /   s    $ JJ&	iit}}223c9YFF]]'')F2N 		%%nZZ&@AIi0IC-77	BCJr   c           
      V   [         R                  R                  U R                  R                  5      S-   nXR	                  SS9R                  S5      -  nUR                  S5      U R                  -  R	                  SS9n[         R                  " [        U5      5      [        U R                  5      -   n[         R                  " U R                  U45      n[         R                  " [         R                  " U R                  SS2SS/4   U45      [         R                  " U R                  SS2SS/4   U45      [         R                  " U R                  SS2SS/4   U45      45      n[         R                  R                  U5      n[        R                  " U S	5      nU" XES
9nU$ )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

Returns
----------
permutated : trimesh.Trimesh
  Mesh with remeshed facets
g?r   )axis)r   r   )r   r   r   Nr      r   )r!   r$   )r   r   r$   r"   sumr   r   arangelenr!   vstackcolumn_stackr   r   r   )r   barycentricvertex_facevertex_face_idr!   r$   r   r   s           r   tessellationr3   P   sW   ( ))""4::#3#34t;K???*227;;K &&z2T^^CHHaHPKYYs;/03t}}3EEN yy$--56HIIOOTZZAq6	2NCDOOTZZAq6	2NCDOOTZZAq6	2NCD	
E II!!%(Ei0IH:Jr   c                   4    \ rS rSrS rSS jrS	S jrS rSrg)

Permutator}   c                     Xl         g)z<
A convenience object to get permutated versions of a mesh.
N_mesh)selfr   s     r   __init__Permutator.__init__~   s	     
r   c                 *    [        U R                  US9$ )N)r   )r   r9   )r:   r   s     r   r   Permutator.transform   s    7HIIr   Nc                 .    [        U R                  U5      $ N)r'   r9   )r:   r%   s     r   r'   Permutator.noise   s    TZZ++r   c                 ,    [        U R                  5      $ r@   )r3   r9   )r:   s    r   r3   Permutator.tessellation   s    DJJ''r   r8   )i  r@   )	__name__
__module____qualname____firstlineno__r;   r   r'   r3   __static_attributes__r   r   r   r5   r5   }   s    J,(r   r5   )g     @@r@   )__doc__numpyr    r   r   r   r   typedr   r   r'   r3   r5   AttributeErrorr   r   r   <module>rN      s     # + v @B*Z( ("	$}}J#,#4#4J &2&:&:J# 		s   AB	 	BB