public void Present(Vector normalVector, double lineResolution, double pointResolution)
        {
            LineResolution = lineResolution;
            Lines.Clear();

            Vector vectorIncrement = normalVector.Normalize() * lineResolution;

            Vector startingPoint;
            Vector endPoint;
            Vector currentVector;
            if (vectorIncrement.X < 0) //для углов 91-180 рисуем, начиная с левого верхнего края - координата (0, Ymax)
            {
                startingPoint = new Vector(0, Image.Height);
                endPoint = new Vector(Image.Width, 0);
                vectorIncrement = vectorIncrement.Reverse();
                currentVector = Line.GetIntersection(new Line(vectorIncrement, startingPoint), new Line(new Vector(-vectorIncrement.Y, vectorIncrement.X), new Vector(0, 0)));
            }
            else // для углов 0-90 с точки (0,0)
            {
                startingPoint = new Vector(0, 0);
                endPoint = new Vector(Image.Width, Image.Height);
                currentVector = vectorIncrement;
            }

            Lines.Add(new ImageLine(vectorIncrement, startingPoint, Image));

            var BorderLine = new Line(vectorIncrement, endPoint);
            var IncrementLine = new Line(new Vector(-vectorIncrement.Y, vectorIncrement.X), new Vector(0, 0));
            var Intersection = Line.GetIntersection(BorderLine, IncrementLine);

            while (currentVector.X <= Intersection.X && (currentVector.Y * Intersection.Y < 0 || Math.Abs(currentVector.Y) <= Math.Abs(Intersection.Y)))
            {
                Lines.Add(new ImageLine(currentVector, Image));
                currentVector += vectorIncrement;
            }

            foreach (var item in Lines)
            {
                item.GeneratePixels(pointResolution);
            }
        }
Exemple #2
0
 public static double GetAngle(Vector v)
 {
     return Math.Acos(v.Normalize().X);
 }