
    Og                    b    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y	)    )annotations)Iterable)Vec3)global_bspline_interpolationBSplineEulerSpiralc                |    |dkD  sJ d       d| g}| }t        |dz
        D ]  }|| z  }|j                  |        |S )N   zrequires count > 2      ?)rangeappend)basecountvalues
next_value_s        [/var/www/html/public_html/myphp/venv/lib/python3.12/site-packages/ezdxf/math/eulerspiral.pypowersr      sW    19***94[FJ519 "d
j!" M    c              #  p   K   t        |       t        |      z  }t        d|dz         D ]	  }||z    y w)Nr      )floatr   )lengthsegmentsdelta_lindexs       r   _paramsr      s<     FmeHo-Gq(Q,' os   46c                  l    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y
)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

    c                X    t        |      }|| _        t        |d      | _        i | _        y )N   )r   	curvaturer   curvature_powers_cache)selfr!   s     r   __init__zEulerSpiral.__init__'   s)    )$	"-3Ir-B)+r   c                2    |dkD  r| j                   d   |z  S y)z%Get radius of circle at distance `t`.g        r
   r"   )r$   ts     r   radiuszEulerSpiral.radius-   s"    s7((+a//r   c                \    |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# 5 5a 889u%%r   c                8    | 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                F     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                4    | 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(   r5   yxs   ``   r   pointzEulerSpiral.point=   s    	
 DKKQ3q!U#$r2w'( r2y)* r2|,	-  q!T"#q!V$% r2x() r2{+	,  "!QZDKKN{{1~r   c              #  T   K   t        ||      D ]  }| j                  |        yw)zyApproximate curve of length with line segments.
        Generates segments+1 vertices as :class:`Vec3` objects.

        N)r   rH   )r$   r   r   r(   s       r   approximatezEulerSpiral.approximateW   s,     
 * 	 A**Q-	 s   &(c                    | j                  |      }| j                  |      }|| j                  |      j                  |      j	                         z   S )z"Get circle center at distance `t`.)rH   r)   r-   	normalize
orthogonal)r$   r(   prs       r   circle_centerzEulerSpiral.circle_center_   sC    JJqMKKN4<<?,,Q/::<<<r   c           	     p   t        |      }t        | j                  ||            }t        ||      D cg c]"  }| j	                  |      j                  |      $ }}t        ||||      }t        |j                  |j                  |j                         D 	cg c]  }	|	|z  	 c}	      S c c}w c c}	w )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   )methodtangents)r   listrJ   r   r-   rL   r   r   control_pointsorderknots)
r$   r   r   degreerR   
fit_pointsr(   derivativessplinevs
             r   bsplinezEulerSpiral.bsplinee   s    & v$**6H*EF

 VX.	
  LLO%%f-
 
 .v
 !!LL!'0AQZ0	
 	

 1s   'B.B3N)r   )r!   r   )r(   r   returnr   )r(   r   r^   r   )r)   r   r^   r   )r   r   r   intr^   zIterable[Vec3])r:   r6   uniform)
r   r   r   r_   rX   r_   rR   strr^   r   )__name__
__module____qualname____doc__r%   r)   r-   r/   rH   rJ   rP   r]    r   r   r   r      sj    	,&
84 = #
#
 #
 	#

 #
 
#
r   N)r   r   r   r_   r^   zlist[float])r   r   r   r_   r^   zIterable[float])
__future__r   typingr   
ezdxf.mathr   ezdxf.math.bspliner   r   __all__r   r   r   rf   r   r   <module>rl      s0    #   D/m
 m
r   