public GetAdjacent ( string ignored ) : string | ||
ignored | string | |
return | string |
public static Node GetCounterClockwiseMostAdjacent(Node prev, Node curr, ref List <Node> _nodes) { if (curr.adjacents == null || curr.adjacents.Count == 0) { return(null); } Vector3 dirCurr = Vector3.zero; dirCurr = curr.Position - prev.Position; Node next = EdgeGraphUtility.GetNode(curr.GetAdjacent(prev.ID), ref _nodes); if (next == null) { return(null); } Vector3 dirNext = next.Position - curr.Position; bool currIsConvex = DotPerp(dirNext, dirCurr) <= 0; foreach (var a in curr.adjacents) { var adj = EdgeGraphUtility.GetNode(a, ref _nodes); Vector3 dirAdj = adj.Position - curr.Position; if (currIsConvex) { if (DotPerp(dirCurr, dirAdj) > 0 && DotPerp(dirNext, dirAdj) > 0) { next = adj; dirNext = dirAdj; currIsConvex = DotPerp(dirNext, dirCurr) <= 0; } } else { if (DotPerp(dirCurr, dirAdj) > 0 || DotPerp(dirNext, dirAdj) > 0) { next = adj; dirNext = dirAdj; currIsConvex = DotPerp(dirNext, dirCurr) <= 0; } } } return(next); }
public static Node GetCounterClockwiseMostAdjacent(Node prev, Node curr, ref List<Node> _nodes) { if (curr.adjacents == null || curr.adjacents.Count == 0) return null; Vector3 dirCurr = Vector3.zero; dirCurr = curr.Position - prev.Position; Node next = EdgeGraphUtility.GetNode(curr.GetAdjacent(prev.ID), ref _nodes); if (next == null) return null; Vector3 dirNext = next.Position - curr.Position; bool currIsConvex = DotPerp(dirNext, dirCurr) <= 0; foreach (var a in curr.adjacents) { var adj = EdgeGraphUtility.GetNode(a, ref _nodes); Vector3 dirAdj = adj.Position - curr.Position; if (currIsConvex) { if (DotPerp(dirCurr, dirAdj) > 0 && DotPerp(dirNext, dirAdj) > 0) { next = adj; dirNext = dirAdj; currIsConvex = DotPerp(dirNext, dirCurr) <= 0; } } else { if (DotPerp(dirCurr, dirAdj) > 0 || DotPerp(dirNext, dirAdj) > 0) { next = adj; dirNext = dirAdj; currIsConvex = DotPerp(dirNext, dirCurr) <= 0; } } } return next; }