zoukankan      html  css  js  c++  java
  • java Earcut

    java Earcut

    Maven dependency:
    <dependency>
      <groupId>io.github.earcut4j</groupId>
      <artifactId>earcut4j</artifactId>
      <version>2.2.2</version>
    </dependency>
     

    使用案例:

    import java.util.List;
    
    import earcut4j.Earcut;
    
    public class Test1 {
        
        public static void main(String[] args) {
            // triangulating a polygon with a hole
            List<Integer> triangles1 = Earcut.earcut(new double[] { 0, 0, 100, 0, 100, 100, 0, 100, 20, 20, 80, 20, 80, 80, 20, 80 }, new int[] { 4 }, 2);
            // [3,0,4, 5,4,0, 3,4,7, 5,0,1, 2,3,7, 6,5,1, 2,7,6, 6,1,2]
            System.out.println(triangles1);
    
            // triangulating a polygon with 3d coords
            List<Integer> triangles2 = Earcut.earcut(new double[] { 10, 0, 1, 0, 50, 2, 60, 60, 3, 70, 10, 4 }, null, 3);
            // [1,0,3, 3,2,1]
            System.out.println(triangles2);
            
        }
    
    }

    输出:

    [3, 0, 4, 5, 4, 0, 3, 4, 7, 5, 0, 1, 2, 3, 7, 6, 5, 1, 2, 7, 6, 6, 1, 2]
    [1, 0, 3, 3, 2, 1]

     

    参考:https://github.com/earcut4j/earcut4j

    ############################3

    QQ 3087438119
  • 相关阅读:
    四则运算2
    进度条博客
    随机生成30道100以内的四则运算题
    构建之法阅读笔记01
    自我介绍
    c# dataGridView cell添加下拉框
    Winform Combobox.Items tooltip
    中医和红外(北京第一个工作)
    pdf修复
    c# 导出数据到excel
  • 原文地址:https://www.cnblogs.com/herd/p/15768994.html
Copyright © 2011-2022 走看看