yI PdZddlmZmZddlZdZdZdZGdde Z dS) a Visvalingam-Whyatt method of poly-line vertex reduction Visvalingam, M and Whyatt J D (1993) "Line Generalisation by Repeated Elimination of Points", Cartographic J., 30 (1), 46 - 51 Described here: http://web.archive.org/web/20100428020453/http://www2.dcs.hull.ac.uk/CISRG/publications/DPs/DP10/DP10.html ========================================= The MIT License (MIT) Copyright (c) 2014 Elliot Hallmark Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================ )IterableListNct|d|d|dz z|d|d|dz zz|d|d|dz zzdz S)z> calculates the area of a triangle given its vertices r@)abs)p1p2p3s /builddir/build/BUILDROOT/lve-stats-4.3.2-1.el9.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/lib/chart/polysimplify.py triangle_arear ,sd r!u11 &A"Q%"Q%-)@@2a5BqETVWXTYMCZZ [ [^` ``cdtjt|f|j}tj|d<tj|d<|dd}|dd}|dd}|dd}tj|}tj|dddf|dddf|tj|dddf||tj|dddf|dddf|tj|dddf||tj|||tj|dddf|dddf|tj|dddf||tj|||tj |||dz}|S) z take an (N,2) array of points and return an (N,1) array of the areas of those triangles, where the first and last areas are np.inf see triangle_area for algorithm rNr)outr) npemptylendtypeinf empty_likesubtractmultiplyaddr)arrresultr r r accracc1s r triangle_areas_from_arrayr!3sXs3xxk39 - -FF1IF2J SbSB QrTB QRRB !B$*-a1 o*>AhK@PRR  )) )I#a>@@@rc|j} |t|}|j|j|k}n#t$r |j}YnwxYw|SrG)r2intr)r0r;rH)r3nr0rIrs r from_numberzVWSimplifier.from_numbersn,  ;"3q66*IXdo 9:FF   XFFF }}s5A A c|dks|dkrtd||t|jzS)NrrzRatio must be 0tDK0>>>>>>rr() __doc__typingrrnumpyrr r!r&objectr(r#rr r[s""H"!!!!!!!aaa   Nn>n>n>n>n>6n>n>n>n>n>r