OwlCyberSecurity - MANAGER
Edit File: tritools.cpython-38.pyc
U ��]�0 � @ s, d Z ddlZddlmZ G dd� de�ZdS )z Tools for triangular grids. � N)� Triangulationc @ sP e Zd ZdZdd� Zedd� �Zddd�Zdd d�Zdd d�Z e ddd��ZdS )�TriAnalyzera� Define basic tools for triangular mesh analysis and improvement. A TriAnalyzer encapsulates a :class:`~matplotlib.tri.Triangulation` object and provides basic tools for mesh analysis and mesh improvement. Parameters ---------- triangulation : :class:`~matplotlib.tri.Triangulation` object The encapsulated triangulation to analyze. Attributes ---------- `scale_factors` c C s t |t�std��|| _d S )NzExpected a Triangulation object)� isinstancer � ValueError�_triangulation)�selfZ triangulation� r �9/usr/lib/python3/dist-packages/matplotlib/tri/tritools.py�__init__ s zTriAnalyzer.__init__c C sT | j �� }tjt�|�| j jjd�dk}dt�| j j| � dt�| j j| � fS )ar Factors to rescale the triangulation into a unit square. Returns *k*, tuple of 2 scale factors. Returns ------- k : tuple of 2 floats (kx, ky) Tuple of floats that would rescale the triangulation : ``[triangulation.x * kx, triangulation.y * ky]`` fits exactly inside a unit square. �Z minlengthr � ) r �get_masked_triangles�np�bincount�ravel�x�sizeZptp�y)r �compressed_trianglesZ node_usedr r r � scale_factors s ���zTriAnalyzer.scale_factorsTc C s: |r| j \}}nd\}}t�| jj| | jj| g�j}|| jj }|dd�ddd�f |dd�ddd�f }|dd�ddd�f |dd�ddd�f }|dd�ddd�f |dd�ddd�f }t�|dd�df |dd�df �}t�|dd�df |dd�df �}t�|dd�df |dd�df �}|| | d } | || | || | || | } | dk}t� |��r�|j d }tj|tjd�} tj | |<