
    Og_&                    h   d dl mZ d dlZd dlmZmZmZmZmZ d dl	m
Z
 ddlmZ ddlmZ g dZd ej                   ddf	 	 	 	 	 	 	 	 	 dd	Z	 	 d	 	 	 	 	 	 	 	 	 dd
Z	 	 	 	 d	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 ddZ	 	 	 d	 	 	 	 	 	 	 	 	 ddZdddZ	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZ	 	 d	 	 	 	 	 	 	 	 	 ddZy)    )annotationsN)cubic_bezier_arc_parametersMatrix44UVecbasic_transformationVec3)forms   )Path)	converter)unit_circleelliptic_transformationrectngonwedgestargearhelixc                    t               }d}t        | ||      D ]%  \  }}}}	|r	||_        d}|j                  |	||       ' ||S |j	                  |      S )ui  Returns a unit circle as a :class:`Path` object, with the center at
    (0, 0, 0) and the radius of 1 drawing unit.

    The arc spans from the start- to the end angle in counter-clockwise
    orientation. The end angle has to be greater than the start angle and the
    angle span has to be greater than 0.

    Args:
        start_angle: start angle in radians
        end_angle: end angle in radians (end_angle > start_angle!)
        segments: count of Bèzier-curve segments, default is one segment for
            each arc quarter (π/2)
        transform: transformation Matrix applied to the unit circle

    TF)r   r   start	curve4_to	transform
start_angle	end_anglesegmentsr   path
start_flagr   ctrl1ctrl2ends
             V/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/path/shapes.pyr   r      sq    * 6DJ$?Y% * ueS DJJsE5)* ~~i((    c                    t               }d}t        | ||      D ]/  \  }}}}	|r|j                  |       d}|j                  |	||       1 |j                  d       ||S |j	                  |      S )u]  Returns a wedge as a :class:`Path` object, with the center at
    (0, 0, 0) and the radius of 1 drawing unit.

    The arc spans from the start- to the end angle in counter-clockwise
    orientation. The end angle has to be greater than the start angle and the
    angle span has to be greater than 0.

    Args:
        start_angle: start angle in radians
        end_angle: end angle in radians (end_angle > start_angle!)
        segments: count of Bèzier-curve segments, default is one segment for
            each arc quarter (π/2)
        transform: transformation Matrix applied to the wedge

    TFr   r   r   )r   r   line_tor   r   r   s
             r"   r   r   @   s    * 6DJ$?Y% * ueS LLJsE5)* 	LL~~i((r#   c                |    |dk  rt        d|       |dk  rt        d|       |}||z  }t        | ||df|      S )uF  Returns the transformation matrix to transform a unit circle into
    an arbitrary circular- or elliptic arc.

    Example how to create an ellipse with a major axis length of 3, a minor
    axis length 1.5 and rotated about 90°::

        m = elliptic_transformation(radius=3, ratio=0.5, rotation=math.pi / 2)
        ellipse = shapes.unit_circle(transform=m)

    Args:
        center: curve center in WCS
        radius: radius of the major axis in drawing units
        ratio: ratio of minor axis to major axis
        rotation: rotation angle about the z-axis in radians

    ư>zinvalid radius: zinvalid ratio: r
   )
ValueErrorr   )centerradiusratiorotationscale_xscale_ys         r"   r   r   e   s[    , }+F8455t|?5'233GunG'1(=xHHr#   c                    | dk  rt        d|        |dk  rt        d|       t        |       dz  }t        |      dz  }t        j                  ||f| |f| | f|| fgd      }||S |j	                  |      S )ae  Returns a closed rectangle as a :class:`Path` object, with the center at
    (0, 0, 0) and the given `width` and `height` in drawing units.

    Args:
        width: width of the rectangle in drawing units, width > 0
        height: height of the rectangle in drawing units, height > 0
        transform: transformation Matrix applied to the rectangle

    g&.>zinvalid width: zinvalid height: g       @Tclose)r)   floatr   from_verticesr   )widthheightr   w2h2r   s         r"   r   r      s     t|?5'233}+F8455	u	B	v	B""
bRC9sRCj2s)4DD ~~i((r#   c                    t        j                  | ||      }||j                  |      }t        j                  |d      S )a  Returns a `regular polygon <https://en.wikipedia.org/wiki/Regular_polygon>`_
    a :class:`Path` object, with the center at (0, 0, 0).
    The polygon size is determined by the edge `length` or the circum `radius`
    argument. If both are given `length` has higher priority. Default size is
    a `radius` of 1. The ngon starts with the first vertex is on the x-axis!
    The base geometry is created by function :func:`ezdxf.render.forms.ngon`.

    Args:
        count: count of polygon corners >= 3
        length: length of polygon side
        radius: circum radius, default is 1
        transform: transformation Matrix applied to the ngon

    )lengthr+   Tr1   )r	   r   transform_verticesr   r4   )countr:   r+   r   verticess        r"   r   r      s?    ( zz%v>H//9""8488r#   c                    t        j                  | ||      }||j                  |      }t        j                  |d      S )a  Returns a `star shape <https://en.wikipedia.org/wiki/Star_polygon>`_ as
    a :class:`Path` object, with the center at (0, 0, 0).

    Argument `count` defines the count of star spikes, `r1` defines the radius
    of the "outer" vertices and `r2` defines the radius of the "inner" vertices,
    but this does not mean that `r1` has to be greater than `r2`.
    The star shape starts with the first vertex is on the x-axis!
    The base geometry is created by function :func:`ezdxf.render.forms.star`.

    Args:
        count: spike count >= 3
        r1: radius 1
        r2: radius 2
        transform: transformation Matrix applied to the star

    )r1r2Tr1   )r	   r   r;   r   r4   )r<   r?   r@   r   r=   s        r"   r   r      s?    " zz%B2.H//9""8488r#   c                    t        j                  | ||||      }||j                  |      }t        j                  |d      S )a{  
    Returns a `gear <https://en.wikipedia.org/wiki/Gear>`_ (cogwheel) shape as
    a :class:`Path` object, with the center at (0, 0, 0).
    The base geometry is created by function :func:`ezdxf.render.forms.gear`.

    .. warning::

        This function does not create correct gears for mechanical engineering!

    Args:
        count: teeth count >= 3
        top_width: teeth width at outside radius
        bottom_width: teeth width at base radius
        height: teeth height; base radius = outside radius - height
        outside_radius: outside radius
        transform: transformation Matrix applied to the gear shape

    Tr1   )r	   r   r;   r   r4   )r<   	top_widthbottom_widthr6   outside_radiusr   r=   s          r"   r   r      sC    4 zz%L&.QH//9""8488r#   c                $   fd}dfd}| | |s t        | ddf      }|t        j                  z   |t        j                  |z        }t	        t        j
                  |            }	|	dkD  ryt         ||t        j                  |            }
t        |	      D ]J  }t        dd|j                  j                        }|
D ]"  \  }}}|j                  ||z   ||z   ||z          $ L ||	z
  }|dkD  rt        j                  |dz        } ||t        j                  z  |z        }t        dd|j                  j                        } ||t        j                  |z  |      D ]"  \  }}}|j                  ||z   ||z   ||z          $ |S )a  
    Returns a `helix <https://en.wikipedia.org/wiki/Helix>`_ as
    a :class:`Path` object.
    The center of the helix is always (0, 0, 0), a positive `pitch` value
    creates a helix along the +z-axis, a negative value along the -z-axis.

    Args:
        radius: helix radius
        pitch: the height of one complete helix turn
        turns: count of turns
        ccw: creates a counter-clockwise turning (right-handed) helix if ``True``
        segments: cubic Bezier segments per turn

    c           	   3  n  K   d}||z  
z  }|dz  }t        d||      D ]  \  }}}}	t        |j                  z  |j                  z  ||z   | z
        t        |j                  z  |j                  z  ||z   | z         t        |	j                  z  |	j                  z  ||z         f ||z  } y w)Ng        g      ?r   )r   r   xy)bangler   zzz_stepz_step_2_v1v2v3prxrys             r"   bezier_ctrl_pointsz!helix.<locals>.bezier_ctrl_points  s     !A%C<8E8L 	MAr2rRTTBYr	2=1+<=RTTBYr	2=1+<=RTTBYr	2;7 
 &LB	s   B2B5c                    t        j                  |       }d|z
  d|z
  z  | z  z  }t        j                  |       d|z
  z  t        j                  |       z  }||z  S )N      ?g      @g      @)mathcossintan)alphacos_ab_1b_2rR   s       r"   param_bzhelix.<locals>.param_b  sY    U{sU{+e3a7hhuou-?Syr#   r   )r   r(      )r\   r3   returnr3   )r   rX   taupiintfloorlistranger   r!   zr   ceil)r+   pitchturnsccwr   rU   r`   r   rI   
full_turnscurve_paramsrN   ri   rO   rP   rQ   reminderrR   rS   rT   s                    @@@r"   r   r      s~   .
 
B	BSvq!n%DA("#ATZZ&'JA~.q$((HEFz" 	7AQ488::&A* 7
Bq2vq2vq2v67	7
 z!H$99X\*Htww&12Atxxzz",Q80CXN 	3JBBNN1r61r61r62	3 Kr#   )
r   r3   r   r3   r   re   r   Matrix44 | Nonerb   r   )r
   N)r%   r
   r
   r   )
r*   r   r+   r3   r,   r3   r-   r3   rb   r   )r
   r
   N)r5   r3   r6   r3   r   rq   rb   r   )NrW   N)
r<   re   r:   zfloat | Noner+   r3   r   rq   rb   r   )N)
r<   re   r?   r3   r@   r3   r   rq   rb   r   )r<   re   rB   r3   rC   r3   r6   r3   rD   r3   r   rq   rb   r   )Tra   )
r+   r3   rk   r3   rl   r3   r   re   rb   r   )
__future__r   rX   
ezdxf.mathr   r   r   r   r   ezdxf.renderr	   r   r    r   __all__rc   r   r   r   r   r   r   r   r    r#   r"   <module>rx      s   #     	 xx!%	!)!)!) !) 	!)
 
!)N !%	")")") ") 	")
 
")L 	III I 	I
 I@ GK))#)4C)	)<  !%	999 9 	9
 
949: "&999 9 	9
 9 9 
9H 	AAA A
 A 
Ar#   