패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.2.0

dart_earcut

https://github.com/mapbox/earcut 기반의 성능 최적화 삼각 분할 알고리즘

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
109만
좋아요
10
Pub 점수
150

패키지 설치

flutter pub add dart_earcut

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

dart_earcut는 Mapbox에서 처음 개발한 Earcut 알고리즘을 구현한 Dart용 고성능 삼각화 라이브러리입니다. 다각형 형태를 효율적으로 삼각형으로 변환하여 2D 그래픽 및 시각화 응용 프로그램에서 복잡한 기하학적 구조를 렌더링하는 데 이상적입니다. 이 패키지는 Android, iOS, Web, macOS, Windows, Linux 등 여러 플랫폼을 지원하며, 크로스플랫폼 일관성을 보장합니다. 속도와 정확성을 중시해 설계되었으며, 구멍이 있는 단순 및 복잡한 다각형을 처리할 수 있어 계산 기하학 작업에 신뢰할 수 있는 결과를 제공합니다.

사용 사례

  • 2D 게임 개발
  • 웹 기반 지도 렌더링
  • 벡터 그래픽 처리
  • 인터랙티브 데이터 시각화
  • UI 컴포넌트용 메시 생성

주요 기능

  • 빠른 삼각 분할 성능
  • 구멍이 있는 다각형을 지원합니다
  • 크로스 플랫폼 호환성
  • 다각형 입력을 위한 간단한 API
  • 복잡한 형태에 대한 정확한 결과

적합한 대상

  • 그래픽 개발자
  • GIS 애플리케이션 제작자
  • 사용자 정의 형태를 사용하는 UI/UX 디자이너
  • 게임 엔진 통합자
  • 데이터 시각화 엔지니어

고려 사항

  • 유효한 다각형 입력이 필요합니다(교차하지 않는 변)
  • 실시간 동적 업데이트에 최적화되지 않음
  • 2차원 삼각화로 제한
  • 자기 교차 다각형을 직접 처리하지 않음
  • 비규칙적인 입력을 위해 사전 처리가 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

dart_earcut

Ear-clipping (earcutting) triangulation algorithm, ported (with minor API differences) from earcut4j/earcut4j and mapbox/earcut. Also includes the fix from mapbox/earcut#91.

Usage

  • 2D (x/y) coordinates, without holes

    • triangulateRaw: expects points in the format [x0, y0, x1, y1, x2, y2, ...]
    • triangulateFromPoints: expects 'dart:math's Point objects
    final triangles = Earcut.triangulateRaw([10,0, 0,50, 60,60, 70,10]);
    final triangles = Earcut.triangulateFromPoints([Point(10, 0), Point(0,50), Point(60,60), Point(70,10)]);
    // Both return [1,0,3, 3,2,1]
    
  • Holes
    A list of hole indicies, if any. For example, [5, 8] for a 12-vertice input would mean one hole with vertices 5-7 and another with 8-11. If you pass a single vertice as a hole, Earcut treats it as a Steiner point.

    final List<int> triangles = Earcut.triangulateRaw([0, 0, 100, 0, 100, 100, 0, 100, 20, 20, 80, 20, 80, 80, 20, 80], holeIndices: [4]);
    // Returns [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2]
    
    • triangulateFromPointsAndHolePoints performs the logic to generate holeIndices when the outline of a polygon and the outline of its holes are available as points seperately.
  • More dimensions
    Expected to be in the format [x0, y0, z0, x1, y1, z1, x2, y2, z2, ...]

    final List<int> triangles = Earcut.triangulateRaw([10, 0, 1, 0, 50, 2, 60, 60, 3, 70, 10, 4], dimensions: 3);
    // Returns [1,0,3, 3,2,1]
    

The Algorithm

The library implements a modified ear slicing algorithm, optimized by z-order curve hashing and extended to handle holes, twisted polygons, degeneracies and self-intersections in a way that doesn't guarantee correctness of triangulation, but attempts to always produce acceptable results for practical data.

It's based on ideas from FIST: Fast Industrial-Strength Triangulation of Polygons by Martin Held andTriangulation by Ear Clipping by David Eberly.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트