Skip to content

Example code for a simple scenario, input List of Points --> output List of Triangles (List of 3 point array)? #95

Answered by gwlucastrig
istinnstudio asked this question in Q&A
Discussion options

You must be logged in to vote

If you have a Path2D object, extracting the points is a separate task. But here's an example of how it would work if you had the points to start with.

There is more explanation on the Tinfour wiki article Three Easy Iterators

  public static void main(String[] args) {
    // make a polygon, just as an example
    int s = 1; // length of side
    int n = 6; // number of sides
    IncrementalTin tin = new IncrementalTin(1.0);
    for(int i=0; i<n; i++){
      double theta = i*2*Math.PI/n;
      double x = s*Math.cos(theta);
      double y = s*Math.sin(theta);
      Vertex v = new Vertex(x, y, 1, i);
      tin.add(v);
    }
   
    // get the triangles
    for(SimpleTriangle triangle:  tin.t…

Replies: 5 comments 13 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by istinnstudio
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
13 replies
@istinnstudio
Comment options

@micycle1
Comment options

@istinnstudio
Comment options

@micycle1
Comment options

@istinnstudio
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants