
    Ti/                     V    d dl ZddlmZ ddlmZ ddlmZm	Z	 ddZ
ddZd	ed
e	fdZdS )    N   )res_path)tol_path)IntegerList      ?c           
        	
 t          j        | t           j                  } |t           j                            t          j        | d          d                                          }t          j        |t          j	        |z  z            }t          t          j        |t          j        t          |           z  t          j        t          |           z                      }t          |          }t          j        dd|          	d	z
  
t          |           dz
  t!          t#                    t          j        t          |                     |           }	
fd|D             }t          j        |d          }t&          j        ret          j        |dd	g         | dd	g         z
  d
z  d          }|t&          j        k                                     sJ t          |          d
k    sJ | dd	g         |dd	g<   |S )ak  
    Parameters
    ----------
    points : (order, dimension) float
      Control points of the bezier curve
      For a 2D cubic bezier, order=3, dimension=2
    count : int, or None
      Number of segments
    scale : float
      Scale of curve
    Returns
    ----------
    discrete: (n, dimension) float
     Points forming a a polyline representation
    dtypeNr   axis   g        r   c                 f    g | ]-\  }}}|z  |z
  z  z                       d           |z  |z  .S ))r   )reshape).0cipntt_ds       L/DATA/AppData/hermes/venv/lib/python3.11/site-packages/trimesh/path/curve.py
<listcomp>z%discretize_bezier.<locals>.<listcomp>-   sU       AHAq!Q$31q5>	"++G44q81<      r   r   )np
asanyarrayfloat64linalgnormdiffsumceilresseg_fracintclipmin_sectionslenmax_sectionslinspacezipbinomialarangetolstrictmergeall)pointscountscaler    iterablestackedresulttestr   r   r   s           @@@r   discretize_bezierr:      s   " ]6444F} y~~bgf1555A~>>BBDDu 4566GE3+c&kk93;KcRXkk;YZZ
 
 JJE 	Ce$$A
'CFaA8A;;	#f++ 6 6??H     LT  G VG!$$$F z  vvq"gB8Q>QGGGsy %%'''''6{{a aWoFAr7OMr   c           
         ddl m} t          j        | t          j                  } t          |          t          |           z
  dz
  }|t          j                            t          j        | d          d          	                                }t          t          j        |t          j        |z  z  t          j        t          |           z  t          j        t          |           z                      }t          j        |d         |d         |          } |||| j        |g          }t          j        |          }|S )a  
    Given a B-Splines control points and knot vector, return
    a sampled version of the curve.

    Parameters
    ----------
    control : (o, d) float
      Control points of the b- spline
    knots : (j,) float
      B-spline knots
    count : int
      Number of line segments to discretize the spline
      If not specified will be calculated as something reasonable

    Returns
    ----------
    discrete : (count, dimension) float
       Points on a polyline version of the B-spline
    r   )splevr
   r   Nr   r   )scipy.interpolater<   r   r   r   r)   r   r    r!   r"   r&   r'   r$   r%   r(   r*   r+   Tcolumn_stack)	controlknotsr4   r5   r<   degreer    ipldiscretes	            r   discretize_bsplinerE   ?   s   , (''''' mG2:666GZZ#g,,&*F}y~~bggA666Q~??CCEEGu,- 3w<</ 3w<</ 
 
 +eAhb	5
1
1CuS5')V455Hx((HOr   r   returnc                     | dk    rddgS | dk    rg dS | dk    rg dS | dk    rg dS | dk    rg d	S d
dl m}  || t          j        | dz                       S )a+  
    Return all binomial coefficients for a given order.

    For n > 5, scipy.special.binom is used, below we hardcode.

    Parameters
    --------------
    n : int
      Order of binomial

    Returns
    ---------------
    binom : (n + 1,) int
      Binomial coefficients of a given order
    r   r   )r   r   r      )r   rH   rH   r      )r   rI      rI   r      )r   rK   
   rL   rK   r   r   )binom)scipy.specialrM   r   r.   )r   rM   s     r   r-   r-   k   s      	Avv1v	
ayy	
a||	
a	
a####''''''uQ	!a%(()))r   )Nr   )numpyr   	constantsr   r$   r   r/   typedr   r   r:   rE   r-    r   r   <module>rS      s        ' ' ' ' ' ' ' ' ' ' ' ' ! ! ! ! ! ! ! !4 4 4 4n) ) ) )X* *D * * * * * *r   