question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how can i get each triangle?

See original GitHub issue
IncrementalTin tin = new IncrementalTin(1.0);
List<Vertex> vertexList = loadPointSet(newlineList);
tin.add(vertexList, null);
			
TinRenderingUtility.drawTin(tin, 500, 500, new File("tin.png"));

I need the three coordinates of each triangle,not a picture,what should i do?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gwlucastrigcommented, May 1, 2019

First off, thank you for your interest in the Tinfour project. Looking at the code example in your post, it looks like you’ve already made good progress in using the Tinfour software.

There are a couple of ways to do what you want. A good place to start would be to use the TriangleCollector. The implementation is efficient and relatively easy to use. Some code follows. For my example, I’ve used randomly generated vertices rather than your loadPointSet() method, but the idea is the same.

package org.tinfour.example.collector;

import java.util.List;
import java.util.function.Consumer;
import org.tinfour.common.IQuadEdge;
import org.tinfour.common.SimpleTriangle;
import org.tinfour.common.Vertex;
import org.tinfour.demo.utils.TestVertices;
import org.tinfour.standard.IncrementalTin;
import org.tinfour.utils.TriangleCollector;
 
public class ExampleTriangleCollector {

	static class ExampleCollector implements Consumer<SimpleTriangle> {
		@Override
		public void accept(SimpleTriangle t) {
			// here we 
			IQuadEdge a = t.getEdgeA();
			IQuadEdge b = t.getEdgeB();
			IQuadEdge c = t.getEdgeC();
			// it is a little confusing here...  we get the first point
			// from each edge.  So for each edge, we call getA().
			// In a future version,  SimpleTriangle will be
			// enhanced with methods named getVertexA(), getVertexB(),
			// and getVertexC() to do this operation in a less confusing manner.    
			Vertex A = a.getA();
			Vertex B = b.getA();
			Vertex C = c.getA();
			System.out.println("Triangle ");
			System.out.println("  A= " + A.toString());
			System.out.println("  B= " + B.toString());
			System.out.println("  C= " + C.toString());   
		}
	}

	public static void main(String[] args) {
		IncrementalTin tin = new IncrementalTin(1.0);
		List<Vertex> vertexList = TestVertices.makeRandomVertices(5, 0);
		tin.add(vertexList, null);
		ExampleCollector collector = new ExampleCollector();
		TriangleCollector.visitSimpleTriangles(tin, collector);
	}
}
0reactions
gwlucastrigcommented, Apr 30, 2021

There is now an iterator for SimpleTriangles in the API

IncrementalTin tin;   //  constructed and populated
int nTriangle = 0;
for(SimpleTriangle triangle:   tin.triangles()){
     nTriangle++;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Triangles: Area - Varsity Tutors
The area A of a triangle is given by the formula A=12bh where b is the base and h is the height of...
Read more >
Solving Triangles - Math is Fun
Such a triangle can be solved by using Angles of a Triangle to find the other angle, and The Law of Sines to...
Read more >
How to find area of triangle (formula walkthrough) (video)
Finding area of triangles ... To find a triangle's area, use the formula area = 1/2 * base * height. Choose a side...
Read more >
Triangle Calculator
Triangles classified based on their internal angles fall into two categories: right or oblique. A right triangle is a triangle in which one...
Read more >
How to Find Area of triangle | Formulas | Examples - Byju's
Area of a triangle is the region covered by its three sides in a plane. Area of a triangle is equal to half...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found