
    j/                     T    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y)    N   )res_path)tol_path)IntegerListc           
      <   t        j                  | t         j                        } |t         j                  j	                  t        j
                  | d      d      j                         }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        |             |       }|D 	
cg c])  \  }}	}
||	z  |||	z
  z  z  j'                  d      |
z  |z  + }}	}}
t        j                  |d      }t(        j*                  rZt        j                  |ddg   | ddg   z
  d	z  d      }|t(        j,                  k  j/                         sJ t        |      d	k\  sJ | ddg   |ddg<   |S c c}
}	}w )
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
    dtyper   axis   g              ?)r   r   r   )np
asanyarrayfloat64linalgnormdiffsumceilresseg_fracintclipmin_sectionslenmax_sectionslinspacezipbinomialarangereshapetolstrictmergeall)pointscountscaler   tt_dniterablecipstackedresulttests                 ?/DATA/.local/lib/python3.12/site-packages/trimesh/path/curve.pydiscretize_bezierr6      s   " ]]64F} yy~~bggf15A~>BBDu 456GGE3++c&k93;K;KcRXk;YZ
 JE 	Ce$A
'CFaA8A;		#f+ 6?H MULTAq!Q$31q5>	"++G4q81<H   VVG!$F zzvvvq"gB8Q>QGsyy %%'''6{a aWoFAr7OMs   .Hc           
      |   ddl m} t        j                  | t        j                        } t        |      t        |       z
  dz
  }|t        j                  j                  t        j                  | d      d      j                         }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   r   r   )scipy.interpolater8   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Tcolumn_stack)	controlknotsr)   r*   r8   degreer   ipldiscretes	            r5   discretize_bsplinerA   ?   s    , ( mmG2::6GZ#g,&*F}yy~~bgggA6Q~?CCEGGu,-  3w</  3w</
 ++eAhb	5
1CS5'))V45Hx(HO    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   rE   rE   r      )r   rF      rF   r      )r   rH   
   rI   rH   r   r   )binom)scipy.specialrJ   r   r"   )r-   rJ   s     r5   r!   r!   k   se      	Av1v	
a	
a	
a	
a##'Q		!a%())rB   )Nr   )numpyr   	constantsr   r   r   r$   typedr   r   r6   rA   r!    rB   r5   <module>rP      s0     ' ' !4n)X* *D *rB   