Horje
c# get every point in a line in matrix Code Example
c# get every point in a line in matrix
public class Line {
    public Point p1, p2;

    public Line(Point p1, Point p2) {
        this.p1 = p1;
        this.p2 = p2;
    }

    public Point[] getPoints(int quantity) {
        var points = new Point[quantity];
        int ydiff = p2.Y - p1.Y, xdiff = p2.X - p1.X;
        double slope = (double)(p2.Y - p1.Y) / (p2.X - p1.X);
        double x, y;

        --quantity;

        for (double i = 0; i < quantity; i++) {
            y = slope == 0 ? 0 : ydiff * (i / quantity);
            x = slope == 0 ? xdiff * (i / quantity) : y / slope;
            points[(int)i] = new Point((int)Math.Round(x) + p1.X, (int)Math.Round(y) + p1.Y);
        }

        points[quantity] = p2;
        return points;
    }
}




Csharp

Related
<link rel="stylesheet" href="styles/kendo.common.min.css" /> Code Example <link rel="stylesheet" href="styles/kendo.common.min.css" /> Code Example
structure in c sharp with example Code Example structure in c sharp with example Code Example
classe padre figlio c# Code Example classe padre figlio c# Code Example
edit opened excel file directly Code Example edit opened excel file directly Code Example
Entity Framework Core 3.1 Return value (int) from stored procedure Code Example Entity Framework Core 3.1 Return value (int) from stored procedure Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
14