The angle of two segments by cosine theorem///////Start point///end point///double A Ngle (PointF o, PointF S, PointF e) {Double COSFI = 0, fi = 0, norm = 0; Double dsx = s.x-o.x; Double dsy = s.y-o.y; Double dex = e.x-o.x; Double dey = e.y-o.y; COSFI = DSX * dex + dsy * dey; Norm = (DSX * dsx + dsy * dsy) * (DEX * dex + dey * dey); COSFI/= math.sqrt (Norm); if (COSFI >= 1.0) return 0; if (COSFI <= -1.0) return Math.PI; fi = Math.acos (COSFI); if (Fi/math.pi < +) {return * FI/MATH.PI; } else {return 360-180 * FI/MATH.PI; }}///<summary>//Convex packet algorithm///</summary>//<param name= "_list" >< ;/param>//<RETURNS></RETURNS> Private list<tuline> Bruteforcetu (list<info> _list) {//record pole pair list<tuline> role = new list<tuline> (); Traverse for (int i = 0; i < _list. Count-1; i++) {for (int j = i + 1; j < _list. Count; J + +) {Double A = _list[j]. Y-_list[i]. Y Double b = _list[i]. X-_list[j]. X Double c = _list[i]. X * _list[j]. Y-_list[i]. Y * _list[j]. X int count = 0; Put all points into the equation for (int k = 0; k < _list. Count; k++) {Double result = a * _list[k]. X + b * _list[k]. Y-c; if (Result > 0) {count++; } else if (Result < 0) {count--; } }//Is the pole, then the connection is recorded if (Math.Abs (count) = = _list. Count-2) {Tuline line = new Tuline (); IPoint pi = new Pointclass (); Pi. X = _list[i]. X Pi. Y = _list[i]. Y Line. Begin = PI; IPoint Pj = new Pointclass (); pj.x = _list[j]. X PJ.Y = _list[j]. Y Line. End = Pj; Role. ADD (line); }}} return role; }
Cosine angle + convex hull algorithm for line segments