private bool IsPointInTriangle(MappedPoint mp, MappedPoint mp0, MappedPoint mp1, MappedPoint mp2) { var p0 = mp0.v2; var p = mp.v2; var p1 = mp1.v2; var p2 = mp2.v2; return(IsPointInTriangle(p, p0, p1, p2)); }
public bool IsVertConvex(MappedPoint prev, MappedPoint curr, MappedPoint next) { float area = 0; area += (next.v2.x - curr.v2.x) * (next.v2.y + curr.v2.y); area += (curr.v2.x - prev.v2.x) * (curr.v2.y + prev.v2.y); area += (prev.v2.x - next.v2.x) * (prev.v2.y + next.v2.y); return(area < 0); }
private int IntersectionCount(SliceHierarchy outerPoints, MappedPoint point) { var intersectionCount = 0; for (var p = outerPoints.Points.First; p != null; p = p.Next) { var end = new Vector2(1000000f, 0); var areIntersect = LineSegmentsIntersection(point.v2, end, p.Value.v2, LinkedListExtensions.Next(p).Value.v2, out var intersection); if (areIntersect) { intersectionCount++; } } return(intersectionCount); }
public void AddSlicePlanePoints(Vector3 point1, Vector3 point2) { var point1M = new MappedPoint(point1, u, v); var point2M = new MappedPoint(point2, u, v); var isLinked = false; var prevLinkedListIdx = -1; var isFirst = true; for (var i = 0; i < _subSlices.Count; i++) { var sl = _subSlices[i]; if (sl == null) { continue; } if (sl.Points.First.Value.v2.Equals(point1M.v2)) { if (!isLinked) { sl.Points.AddFirst(point2M); prevLinkedListIdx = i; isLinked = true; isFirst = true; } else { LinkListsFirst(i, prevLinkedListIdx, isFirst); break; } } else if (sl.Points.First.Value.v2.Equals(point2M.v2)) { if (!isLinked) { sl.Points.AddFirst(point1M); prevLinkedListIdx = i; isLinked = true; isFirst = true; } else { LinkListsFirst(i, prevLinkedListIdx, isFirst); break; } } else if (sl.Points.Last.Value.v2.Equals(point1M.v2)) { if (!isLinked) { sl.Points.AddLast(point2M); prevLinkedListIdx = i; isLinked = true; isFirst = false; } else { LinkListsLast(i, prevLinkedListIdx, isFirst); break; } } else if (sl.Points.Last.Value.v2.Equals(point2M.v2)) { if (!isLinked) { sl.Points.AddLast(point1M); prevLinkedListIdx = i; isLinked = true; isFirst = false; } else { LinkListsLast(i, prevLinkedListIdx, isFirst); break; } } } if (!isLinked) { _subSlices.Add(new SliceHierarchy()); _subSlices[_subSlices.Count - 1].Points.AddFirst(point1M); _subSlices[_subSlices.Count - 1].Points.AddFirst(point2M); } }
public bool Equals(MappedPoint obj) { return(v3.Equals(obj.v3) && v2.Equals(obj.v2)); }
public Triangle(MappedPoint a, MappedPoint b, MappedPoint c) { A = a; B = b; C = c; }