public CoordinatMotion(Vector position, int intensity, int feed, Color color) : base(position) { Intensity = intensity; Feed = feed; Color = color; }
public Bezier(Vector start, Vector end, Vector pStart, Vector pEnd) { Start = start; End = end; PStart = pStart; PEnd = pEnd; }
//конструктор прямой через вектор нормали и точку public Line(Vector normalVector, Vector pointToCross) { A = normalVector.X; B = normalVector.Y; C = -(A * pointToCross.X + B * pointToCross.Y); }
public void GeneratePixels(double pointResolution) { var directionVector = new Vector(-B, A).Normalize() * pointResolution; // _NormalVector.Normalize().Rotate90CCW() * pointResolution; if (directionVector.X < 0) directionVector = directionVector.Reverse(); var currentVector = GetFirstVector(); IInterpolator inter = InterpolateHelper.CurrentInterpolator; //наполняем пикселями Pixel temp = _Image.GetPixel(currentVector.X, currentVector.Y);//inter.GetPixel(_Image, currentVector); while (temp != null) { _Pixels.Add(temp); currentVector += directionVector; temp = _Image.GetPixel(currentVector.X, currentVector.Y);//inter.GetPixel(_Image, currentVector); } var lastAddedVector = currentVector - directionVector; var lastVector = GetLastVector(); if (lastAddedVector.X != lastVector.X && lastAddedVector.Y != lastVector.Y) { _Pixels.Add(_Image.GetPixel(lastVector.X, lastVector.Y)); } }
public ImageByLinesPresenter CreatePresenter() { var ip = new ImageByLinesPresenter(_image); var angleInRadian = AngleToVector.DegToRad(_Angle); var mathVector = AngleToVector.GetNormal(angleInRadian); var resultingVector = new Vector(Math.Round(mathVector.X, 6), Math.Round(mathVector.Y, 6)); ip.Present(resultingVector, _LineRes, _PointRes); return ip; }
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); } }
public FreeMotionStroke(Vector destinationPoint) { DestinationPoint = destinationPoint; }
public Pixel(double intencity, Vector v) : this(intencity, v.X, v.Y) { }
//конструктор прямой через вектор нормали и точку public ImageLine(Vector normalVector, Vector pointToCross, Image image) : base(normalVector, pointToCross) { _Pixels = new List<Pixel>(); _Image = image; }
public ArcMotion(Vector position, double r, int intensity, int feed, Color color) : base(position, intensity, feed, color) { R = r; }
//closestPoint - ближайшая точка прямой //pointForDirection - любая точка на линии разгона public IdleStroke(Vector destination) : base(destination, 0) { }
//контструктор прямой через вектор нормали. А координаты точки совпадают с координатами вектора нормали public Line(Vector normalVector) : this(normalVector, normalVector) { }
public VisualLine(Vector v1, Vector v2, double intensity) { _v1 = v1; _v2 = v2; _intensity = intensity; }
public RapidMotion(Vector position, string comment) : this(position) { Comment = comment; }
public RapidMotion(Vector position) : base(position) { }
public CoordinatMotion(Vector position, int intensity, int feed) : this(position, intensity, feed, Color.Black) { }
public static double GetAngle(Vector v) { return Math.Acos(v.Normalize().X); }
public ArcMotion(Vector position, double r, int intensity, int feed) : base(position, intensity, feed) { R = r; }
//контструктор прямой через вектор нормали. А координаты точки, через которую проходит прямая, совпадают с координатами вектора нормали public ImageLine(Vector normalVector, Image image) : this(normalVector, normalVector, image) { }
public static double GetLength(Vector a, Vector b) { return Math.Sqrt((a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y)); }
public Stroke(Vector destinationPoint, double intensity) : base(destinationPoint) { Intensity = intensity; }
public BaseMotion(Vector position) : base("") { Position = position; }