"c# get every point in a line in matrix" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c# get every point in a line in matrix" answered properly. Developers are finding an appropriate answer about c# get every point in a line in matrix related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c# get every point in a line in matrix. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c# get every point in a line in matrix.
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;
}
}
Source: stackoverflow.com
All those coders who are working on the C# based application and are stuck on c# get every point in a line in matrix can get a collection of related answers to their query. Programmers need to enter their query on c# get every point in a line in matrix related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# get every point in a line in matrix for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c# get every point in a line in matrix while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c# get every point in a line in matrix". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# get every point in a line in matrix resolved professionally and stay updated to the latest C# updates.