示例#1
0
        private static int GetNewX(IList <Point> points, int y, int outerPtIndex, int outerY)
        {
            int newX;

            if (outerY <= y || outerPtIndex == 0)
            {
                newX = points[outerPtIndex].GetIntX();
            }
            else
            {
                //if we are here we have found the first outerY where outerY > y and there has to be an inner point as well

                var innerPtIndex = outerPtIndex - 1;
                var innerY       = points[innerPtIndex].GetIntY();

                if (innerY == y)
                {
                    newX = points[innerPtIndex].GetIntX();
                }
                else
                {
                    var innerX = points[innerPtIndex].GetIntX();
                    var outerX = points[outerPtIndex].GetIntX();

                    //this check is important otherwise line creation may fail
                    if (innerX == outerX)
                    {
                        newX = innerX;
                    }
                    else
                    {
                        var lineEquation = LineEquation2D.Get2DLineEquation(innerX, innerY, outerX, outerY);
                        newX = Convert.ToInt32(lineEquation.GetXValueForY(y));
                    }
                }
            }
            return(newX);
        }
示例#2
0
        public LinePtsProcessor(IEnumerable <Point> initializingPts)
        {
            var xYPts = GetReOrderedPoints(initializingPts);

            _lineEqn = StraightLineProcessor.Get2DStraightLineFromDataConstants(xYPts);
        }