Cosine angle + convex hull algorithm for line segments

Source: Internet
Author: User
Tags ipoint

        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" >&lt ;/param>//&LT;RETURNS&GT;&LT;/RETURNS&GT 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.