/// <summary> /// 凸多角形の再分割処理 /// </summary> public static ConvexPolygon Execute(ConvexPolygon polygon, float angleThreshold, float t = 0.5f) { //入力がnullならnullを返す if (polygon == null) { return(null); } //諸々のデータ構造 List <Vector2> results = new List <Vector2>(); //計算結果 List <Vector2> temp = new List <Vector2>(); //一時データ List <Vector2> vertices = polygon.GetVerticesCopy(); //はじめに2点追加 temp.Add(vertices[0]); temp.Add(vertices[1]); //巡回 int size = vertices.Count; for (int i = 2; i <= size; ++i) { //順次処理 temp.Add(vertices[i % size]); Process(temp, results, angleThreshold, t); //処理 } //0番目の処理 temp.Add(results[0]); Process(temp, results, angleThreshold, t); //処理 return(new ConvexPolygon(results)); }
public static ConvexPolygon Execute(ConvexPolygon polygon, int num, float t = 0.5f) { //入力がnullならnullを返す if (polygon == null) { return(null); } //諸々のデータ構造 List <Vector2> vertices = polygon.GetVerticesCopy(); //回数分だけ実行 for (int i = 0; i < num; ++i) { vertices = Process(vertices, t); } return(new ConvexPolygon(vertices)); }