ó
    gzi?   ã                   ól   • S r SSKJrJrJrJr  SSKrSSKr/ SQr	S r
S rSS jrSS jrSS	 jrSS
 jrg)zBAffine transforms, both in general and specific, named transforms.é    )ÚcosÚpiÚsinÚtanN)Úaffine_transformÚrotateÚscaleÚskewÚ	translatec                 ób  ^^^^^^^	^
^^^^^• [        U5      S:X  a+  SmUu  mmmmmmU R                  (       a  SmSmS=m=m=m	=m
mO?[        U5      S:X  a%  SmUu  mmmmmmm	m
mmmmU R                  (       d  SmO[        S5      eUUUUUUU	U
UUUUU4S jn[        R                  " XTS:H  S	9$ )
aÈ  Return a transformed geometry using an affine transformation matrix.

The coefficient matrix is provided as a list or tuple with 6 or 12 items
for 2D or 3D transformations, respectively.

For 2D affine transformations, the 6 parameter matrix is::

    [a, b, d, e, xoff, yoff]

which represents the augmented matrix::

    [x']   / a  b xoff \ [x]
    [y'] = | d  e yoff | [y]
    [1 ]   \ 0  0   1  / [1]

or the equations for the transformed coordinates::

    x' = a * x + b * y + xoff
    y' = d * x + e * y + yoff

For 3D affine transformations, the 12 parameter matrix is::

    [a, b, c, d, e, f, g, h, i, xoff, yoff, zoff]

which represents the augmented matrix::

    [x']   / a  b  c xoff \ [x]
    [y'] = | d  e  f yoff | [y]
    [z']   | g  h  i zoff | [z]
    [1 ]   \ 0  0  0   1  / [1]

or the equations for the transformed coordinates::

    x' = a * x + b * y + c * z + xoff
    y' = d * x + e * y + f * z + yoff
    z' = g * x + h * y + i * z + zoff
é   é   é   ç      ð?ç        é   z,'matrix' expects either 6 or 12 coefficientsc                 ó”  >• TS:X  aM  U R                   u  pTU-  T	U-  -   T-   nTU-  TU-  -   T-   n[        R                  " X4/5      R                   nU$ TS:X  am  U R                   u  pnTU-  T	U-  -   T
U-  -   T-   nTU-  TU-  -   TU-  -   T-   nTU-  TU-  -   TU-  -   T-   n[        R                  " X4U/5      R                   nW$ )Nr   r   )ÚTÚnpÚstack)ÚcoordsÚxÚyÚxpÚypÚresultÚzÚzpÚaÚbÚcÚdÚeÚfÚgÚhÚiÚndimÚxoffÚyoffÚzoffs           €€€€€€€€€€€€€ÚM/home/mande/repo/quber/.venv/lib/python3.13/site-packages/shapely/affinity.pyÚ_affine_coordsÚ(affine_transform.<locals>._affine_coordsH   sð   ø€ ð
 �1‹9Ø—8‘8‰DˆAØ�Q‘˜˜Q™‘ Ñ%ˆBØ�Q‘˜˜Q™‘ Ñ%ˆBÜ—X’X˜r˜hÓ'×)Ñ)ˆFð ˆð �Q‹YØ—h‘h‰GˆA�!Ø�Q‘˜˜Q™‘  Q¡Ñ&¨Ñ-ˆBØ�Q‘˜˜Q™‘  Q¡Ñ&¨Ñ-ˆBØ�Q‘˜˜Q™‘  Q¡Ñ&¨Ñ-ˆBÜ—X’X˜r r˜lÓ+×-Ñ-ˆFØˆó    )Ú	include_z)ÚlenÚhas_zÚ
ValueErrorÚshapelyÚ	transform)ÚgeomÚmatrixr-   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   s      @@@@@@@@@@@@@r,   r   r      sÅ   ÿü€ ôL ˆ6ƒ{�aÓØˆØ!'Ñˆˆ1ˆa��D˜$Ø�:�:ØˆDØˆAØ#&Ð&ˆAÐ&�Ð&�AÐ&˜˜DøÜ	ˆV‹˜Ó	ØˆØ6<Ñ3ˆˆ1ˆa��A�q˜!˜Q  4¨¨tØ�z�zØˆDøäÐGÓHÐH÷÷ ñ ô$ ×Ò˜T¸TÀQ¹YÑGÐGr/   c                 óŠ  • US:X  a  U R                   u  p4pVXS-   S-  Xd-   S-  4nOeUS:X  a  U R                  R                  S   nOE[        U[        5      (       a  [        SU< S35      e[        USS5      S	:X  a  UR                  S   n[        U5      S
;  a  [        S5      eUS:X  a  USS $ [        U5      S:X  a  US-   $ U$ )a!  Return interpreted coordinate tuple for origin parameter.

This is a helper function for other transform functions.

The point of origin can be a keyword 'center' for the 2D bounding box
center, 'centroid' for the geometry's 2D centroid, a Point object or a
coordinate tuple (x0, y0, z0).
Úcenterg       @Úcentroidr   z'origin' keyword z is not recognizedÚ	geom_typeNÚPoint)r   r   z8Expected number of items in 'origin' to be either 2 or 3r   )r   )Úboundsr:   r   Ú
isinstanceÚstrr3   Úgetattrr1   )r6   Úoriginr(   ÚminxÚminyÚmaxxÚmaxys          r,   Úinterpret_originrF   ]   sØ   € ð �Óà!%§¡Ñˆ�DØ‘; #Ñ%¨©°sÑ':Ð;‰Ø	�:Ó	Ø—‘×%Ñ% aÑ(‰Ü	�FœC×	 Ñ	 ÜÐ,¨V©JÐ6HÐIÓJÐJÜ	�˜ dÓ	+¨wÓ	6Ø—‘˜qÑ!ˆô ˆ6ƒ{˜&Ó ÜÐSÓTÐTØˆqƒyØ�a˜ˆ{Ðäˆv‹;˜!ÓØ˜F‘?Ð"àˆMr/   c                 ó2  • U R                   (       a  U $ U(       d  U[        -  S-  n[        U5      n[        U5      n[	        U5      S:  a  Sn[	        U5      S:  a  Sn[        XS5      u  pgXE* SXTSSSSXfU-  -
  Xu-  -   XvU-  -
  Xt-  -
  S4n[        X5      $ )a­  Return a rotated geometry on a 2D plane.

The angle of rotation can be specified in either degrees (default) or
radians by setting ``use_radians=True``. Positive angles are
counter-clockwise and negative are clockwise rotations.

The point of origin can be a keyword 'center' for the bounding box
center (default), 'centroid' for the geometry's centroid, a Point object
or a coordinate tuple (x0, y0).

The affine transformation matrix for 2D rotation is:

  / cos(r) -sin(r) xoff \
  | sin(r)  cos(r) yoff |
  \   0       0      1  /

where the offsets are calculated from the origin Point(x0, y0):

    xoff = x0 - x0 * cos(r) + y0 * sin(r)
    yoff = y0 - x0 * sin(r) - y0 * cos(r)
ç     €f@çVçž¯²<r   r   r   )Úis_emptyr   r   r   ÚabsrF   r   )	r6   ÚanglerA   Úuse_radiansÚcospÚsinpÚx0Úy0r7   s	            r,   r   r   ~   s®   € ð, ‡}‡}ØˆÞØœ‘
˜UÑ"ˆÜˆu‹:€DÜˆu‹:€DÜ
ˆ4ƒy�7ÓØˆÜ
ˆ4ƒy�7ÓØˆÜ˜d¨AÓ.�F€Bð �E˜3Ø˜#Ø�3˜Ø˜‘9‰n˜r™yÑ(¨"°D©y©.¸2¹9Ñ*DÀcðK€Fô
 ˜DÓ)Ð)r/   c                 ó–   • U R                   (       a  U $ [        XS5      u  pVnUSSSUSSSUXUU-  -
  XfU-  -
  XwU-  -
  4n[        X5      $ )a~  Return a scaled geometry, scaled by factors along each dimension.

The point of origin can be a keyword 'center' for the 2D bounding box
center (default), 'centroid' for the geometry's 2D centroid, a Point
object or a coordinate tuple (x0, y0, z0).

Negative scale factors will mirror or reflect coordinates.

The general 3D affine transformation matrix for scaling is:

    / xfact  0    0   xoff \
    |   0  yfact  0   yoff |
    |   0    0  zfact zoff |
    \   0    0    0     1  /

where the offsets are calculated from the origin Point(x0, y0, z0):

    xoff = x0 - x0 * xfact
    yoff = y0 - y0 * yfact
    zoff = z0 - z0 * zfact
r   r   )rJ   rF   r   )	r6   ÚxfactÚyfactÚzfactrA   rP   rQ   Úz0r7   s	            r,   r	   r	   ©   se   € ð, ‡}‡}ØˆÜ! $°Ó2�J€BˆBð �S˜#Ø�5˜#Ø�3˜Ø˜‘:‰o˜r¨¡J™°¸%±Z±ðA€Fô
 ˜DÓ)Ð)r/   c                 ó4  • U R                   (       a  U $ U(       d  U[        -  S-  nU[        -  S-  n[        U5      n[        U5      n[        U5      S:  a  Sn[        U5      S:  a  Sn[	        XS5      u  pxSUSUSSSSSU* U-  U* U-  S4n	[        X	5      $ )ac  Return a skewed geometry, sheared by angles along x and y dimensions.

The shear angle can be specified in either degrees (default) or radians
by setting ``use_radians=True``.

The point of origin can be a keyword 'center' for the bounding box
center (default), 'centroid' for the geometry's centroid, a Point object
or a coordinate tuple (x0, y0).

The general 2D affine transformation matrix for skewing is:

    /   1    tan(xs) xoff \
    | tan(ys)  1     yoff |
    \   0      0       1  /

where the offsets are calculated from the origin Point(x0, y0):

    xoff = -y0 * tan(xs)
    yoff = -x0 * tan(ys)
rH   rI   r   r   r   )rJ   r   r   rK   rF   r   )
r6   ÚxsÚysrA   rM   ÚtanxÚtanyrP   rQ   r7   s
             r,   r
   r
   Ì   s­   € ð* ‡}‡}ØˆÞØ”"‰W�u‰_ˆØ”"‰W�u‰_ˆÜˆr‹7€DÜˆr‹7€DÜ
ˆ4ƒy�7ÓØˆÜ
ˆ4ƒy�7ÓØˆÜ˜d¨AÓ.�F€Bð �4˜Ø�C˜Ø�3˜Øˆc�D‰j˜2˜# ™* cð+€Fô
 ˜DÓ)Ð)r/   c                 óX   • U R                   (       a  U $ SSSSSSSSSXU4n[        X5      $ )zÜReturn a translated geometry shifted by offsets along each dimension.

The general 3D affine transformation matrix for translation is:

    / 1  0  0 xoff \
    | 0  1  0 yoff |
    | 0  0  1 zoff |
    \ 0  0  0   1  /
r   r   )rJ   r   )r6   r)   r*   r+   r7   s        r,   r   r   ÷   s@   € ð ‡}‡}Øˆð �3˜Ø�3˜Ø�3˜Ø˜$ð €Fô
 ˜DÓ)Ð)r/   )r9   F)r   r   r   r9   )r   r   r9   F)r   r   r   )Ú__doc__Úmathr   r   r   r   Únumpyr   r4   Ú__all__r   rF   r   r	   r
   r   © r/   r,   Ú<module>rb      s>   ðÙ Hç "Ó "ã ã â
F€òNHòbôB(*ôV *ôF(*õV*r/   