Triangulation.TriangleContains2d(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3)

Here are the examples of the csharp api Triangulation.TriangleContains2d(UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3, UnityEngine.Vector3) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Examples 7

19 View Source File : Triangulation.cs
License : GNU General Public License v3.0
Project Creator : NoteCAD

public static List<Vector3> Triangulate(List<Vector3> points, LineCanvas canvas = null) {
		List<Vector3> result = new List<Vector3>();
		bool processed = true;
		while(points.Count > 2 && processed) {
			processed = false;
			for(int i = 0; i < points.Count; i++) {
				var a = points[(i - 1 + points.Count) % points.Count];
				var b = points[i];
				var c = points[(i + 1) % points.Count];

				if(IsConvex(a, b, c)) {
					bool contains = false;
					for(int j = 0; j < points.Count; j++) {
						if(j == i || j == i - 1 || j == i + 1) continue;
						if(!TriangleContains2d(a, b, c, points[j])) continue;
						contains = true;
						break;
					}
					if(!contains) {
						if(canvas) {
							canvas.DrawLine(a, b);
							canvas.DrawLine(b, c);
							canvas.DrawLine(c, a);
						}
						result.Add(a);
						result.Add(b);
						result.Add(c);
						points.RemoveAt(i--);
						processed = true;
						if(points.Count < 3) break;
					}
				}
			}
		}
		return result;
	}