o
    &?es                     @   s.   d dl Zd dlmZmZ d	ddZdd ZdS )
    N)	ellipkinc	ellipeinc      ?r   r   Fc              	   C   s  | dks|dks|dkrt dtjd tj|  }ttj| ||f  | }ttj| ||f | d }tdD ]6}|| ||  d dkrQ||  d8  < t|| || || }	d|	vrq||  t|	|	dk  8  < q;tj|d |d |d |d |d |d |d |d |d f \}
}}|s|
t	|  d |t	| d  |t	| d  dk}|S |
t	|  d |t	| d  |t	| d  d }|S )a  
    Generates ellipsoid with semimajor axes aligned with grid dimensions
    on grid with specified `spacing`.

    Parameters
    ----------
    a : float
        Length of semimajor axis aligned with x-axis.
    b : float
        Length of semimajor axis aligned with y-axis.
    c : float
        Length of semimajor axis aligned with z-axis.
    spacing : tuple of floats, length 3
        Spacing in (x, y, z) spatial dimensions.
    levelset : bool
        If True, returns the level set for this ellipsoid (signed level
        set about zero, with positive denoting interior) as np.float64.
        False returns a binarized version of said level set.

    Returns
    -------
    ellip : (N, M, P) array
        Ellipsoid centered in a correctly sized array for given `spacing`.
        Boolean dtype unless `levelset=True`, in which case a float array is
        returned with the level set above 0.0 representing the ellipsoid.

    r   &Parameters a, b, and c must all be > 0)   r   r   r         )

ValueErrornpZr_ceilfloorrangeZarangemaxZmgridfloat)abcspacingZlevelsetoffsetlowhighdimnumxyzZarr r   T/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/skimage/draw/draw3d.py	ellipsoid   sB   r   c                 C   s  | dks|dks|dkrt d| ||g}|jdd |d } |d }|d }dtj |  | | }td|d | d	   d
 }t| d |d  d
 }| d |d |d   t|d | d |d    }t||}t||}	dtj |d ||d  | |  || |	   }
||
fS )a  
    Calculates analytical surface area and volume for ellipsoid with
    semimajor axes aligned with grid dimensions of specified `spacing`.

    Parameters
    ----------
    a : float
        Length of semimajor axis aligned with x-axis.
    b : float
        Length of semimajor axis aligned with y-axis.
    c : float
        Length of semimajor axis aligned with z-axis.

    Returns
    -------
    vol : float
        Calculated volume of ellipsoid.
    surf : float
        Calculated surface area of ellipsoid.

    r   r   T)reverser   r	   gUUUUUU?r   g       @g      ?)r
   sortr   piZarcsinr   ellip_Fellip_E)r   r   r   abcZvolphidmFEZsurfr   r   r   ellipsoid_statsB   s*   



r+   )r   F)	numpyr   Zscipy.specialr   r#   r   r$   r   r+   r   r   r   r   <module>   s    
=