Пример #1
0
        private Int32 calcNumOfPts(double coordAngle, out Coordinates endPoint)
        {
            //first check if value arcTan + alpha exists in the sortedlist
            //if it does then the number of points between pts.arctan & arctan+alpha is the answer
            //else loop through list starting from the given coordinates/arctan till we reach arctan+alpha
            // if the difference between anytwo consective arctans in list is greater than alpha skip it

            Int32 begIndex = coordPts.FindIndex((Coordinates c) => c.tanDegree == coordAngle);
            Int32 endIndex = coordPts.FindIndex((Coordinates c) => c.tanDegree == coordAngle + angAlpha);
            double endVal = coordAngle + angAlpha;
            endPoint = null;

            if (((begIndex + 1) < coordPts.Count) && coordPts.ElementAt(begIndex + 1).tanDegree - coordAngle > angAlpha)
                return 0;

            if (endIndex > 0)
            {
                endPoint = coordPts.ElementAt(endIndex);
                return (endIndex - begIndex);
            }

            endIndex = begIndex;
            Int32 count = 0;
            while (endIndex < coordPts.Count && coordPts.ElementAt(endIndex).tanDegree <= endVal)
            {
                count++; endIndex++;
            }
            endPoint = coordPts.ElementAt(endIndex-1);//as index is incrememnted in the loop
            return count;
        }
Пример #2
0
        public double getAngleBeta()
        {
            //sort the list
            coordPts = coordPts.OrderBy(x => x.tanDegree).ToList();
            Int32 tmp = 0;
            Coordinates xyPt=null;
            Coordinates startCrd = null;

            foreach (var pts in coordPts)
            {
                if (pts.isValid)
                {
                    tmp = calcNumOfPts(pts.tanDegree, out xyPt);
                    if (maxPoint <= tmp)
                    {
                        maxPoint = tmp; endCrd = xyPt; startCrd = pts;
                    }
                }
            }
            //if we draw an angle alpha using two startCrd & endCrd with angle at coordinate origin
            // the lower value will be closer to the axis
            //so the angle beta will be the angle that startcrd will make with x axis of 1st quad.
            return startCrd.tanDegree;
        }