
    'j                    j    d dl mZ d dlmZ d dlmZ d dlmZmZ dgZ	ddZ
ddZ G d d          ZdS )    )annotations)Iterable)Vec3)global_bspline_interpolationBSplineEulerSpiralbasefloatcountintreturnlist[float]c                    |dk    s
J d            d| g}| }t          |dz
            D ]}|| z  }|                    |           |S )N   zrequires count > 2      ?)rangeappend)r	   r   values
next_value_s        P/DATA/AppData/hermes/venv/lib/python3.11/site-packages/ezdxf/math/eulerspiral.pypowersr      sc    1999*9994[FJ519 " "d
j!!!!M    lengthsegmentsIterable[float]c              #     K   t          |           t          |          z  }t          d|dz             D ]	}||z  V  
d S )Nr      )r
   r   )r   r   delta_lindexs       r   _paramsr!      sV      FmmeHoo-Gq(Q,''  o r   c                  \    e Zd ZdZdddZddZd d
Zd!dZd dZd"dZ	d dZ
	 	 	 d#d$dZdS )%r   z
    This class represents an euler spiral (clothoid) for `curvature` (Radius of
    curvature).

    This is a parametric curve, which always starts at the origin = ``(0, 0)``.

    Args:
        curvature: radius of curvature

    r   	curvaturer
   c                j    t          |          }|| _        t          |d          | _        i | _        d S )N   )r
   r#   r   curvature_powers_cache)selfr#   s     r   __init__zEulerSpiral.__init__'   s3    )$$	"-3Ir-B-B)+r   tr   c                2    |dk    r| j         d         |z  S dS )z%Get radius of circle at distance `t`.g        r   r&   )r(   r*   s     r   radiuszEulerSpiral.radius-   s#    s77(+a//3r   r   c                V    |dz  d| j         d         z  z  }t          j        |          S )z4Get tangent at distance `t` as :class:`Vec3` object.r   g       @)r&   r   
from_angle)r(   r*   angles      r   tangentzEulerSpiral.tangent4   s-    Q# 5a 889u%%%r   r-   c                <    | j         d         t          |          z  S )z(Get distance L from origin for `radius`.r   )r&   r
   )r(   r-   s     r   distancezEulerSpiral.distance9   s    $Q'%--77r   c                l     fd} j         vr |ddd           |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
   |ddd          z   }t          ||           j         <    j                  S )z+Get point at distance `t` as :class:`Vec3`.c                0    | z  |j         |         z  z  S )Nr,   )length_powercurvature_powerconstr(   r*   s      r   termzEulerSpiral.point.<locals>.term@   s%    $-o>> r      r   g      @      g      u@   
   g     @      g     ubAr%      g     MA      g      D@	      g      @      g     H"A      g     A)r'   r   )r(   r*   r9   yxs   ``   r   pointzEulerSpiral.point=   s(   	 	 	 	 	 	
 DKQ3$q!U##$$r2w''( $r2y))* $r2|,,	-  $q!T""#$q!V$$% $r2x(() $r2{++	,  "!QZZDKN{1~r   r   r   r   Iterable[Vec3]c              #  ^   K   t          ||          D ]}|                     |          V  dS )zyApproximate curve of length with line segments.
        Generates segments+1 vertices as :class:`Vec3` objects.

        N)r!   rL   )r(   r   r   r*   s       r   approximatezEulerSpiral.approximateW   sD      
 ** 	  	 A**Q--	  	 r   c                    |                      |          }|                     |          }||                     |                              |                                          z   S )z"Get circle center at distance `t`.)rL   r-   r1   	normalize
orthogonal)r(   r*   prs       r   circle_centerzEulerSpiral.circle_center_   sO    JJqMMKKNN4<<??,,Q//::<<<<r   r>   r:   uniformdegreemethodstrr   c                >    t                    t                               |                    } fdt          |          D             }t	          ||||          }t          |j        |j        fd|                                D                       S )a?  Approximate euler spiral as B-spline.

        Args:
            length: length of euler spiral
            segments: count of fit points for B-spline calculation
            degree: degree of BSpline
            method: calculation method for parameter vector t

        Returns:
            :class:`BSpline`

        )r   c                `    g | ]*}                     |                                        +S  )r1   rQ   ).0r*   r   r(   s     r   
<listcomp>z'EulerSpiral.bspline.<locals>.<listcomp>z   sC     
 
 
  LLOO%%f--
 
 
r   )rX   tangentsc                    g | ]}|z  S r\   r\   )r]   vr   s     r   r^   z'EulerSpiral.bspline.<locals>.<listcomp>   s    000AQZ000r   )	r
   listrO   r!   r   r   control_pointsorderknots)r(   r   r   rW   rX   
fit_pointsderivativessplines   ``      r   bsplinezEulerSpiral.bsplinee   s    & v$**6H*EEFF

 
 
 
 
 VX..	
 
 
 .v
 
 
 !L0000000	
 
 	
r   N)r   )r#   r
   )r*   r
   r   r
   )r*   r
   r   r   )r-   r
   r   r
   )r   r
   r   r   r   rM   )r>   r:   rV   )
r   r
   r   r   rW   r   rX   rY   r   r   )__name__
__module____qualname____doc__r)   r-   r1   r3   rL   rO   rU   ri   r\   r   r   r   r      s        	 	, , , , ,   & & & &
8 8 8 8   4       = = = = #
 #
 #
 #
 #
 #
 #
r   N)r	   r
   r   r   r   r   )r   r
   r   r   r   r   )
__future__r   typingr   
ezdxf.mathr   ezdxf.math.bspliner   r   __all__r   r!   r   r\   r   r   <module>rs      s    # " " " " "             D D D D D D D D/      m
 m
 m
 m
 m
 m
 m
 m
 m
 m
r   