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;
}
}
Also in C#:
- unity c# write line
- How to set an expiry date on a program
- if statement conditions c#
- c# method info extension
- c# string
- textblock line break
- texture to image unity
- chase object unity
- unity material offset script
- read embedded resource c# xml
- c# string replace comma with newline
- object escape player unity
- stop unity editor playing
- c# select first value from list
- C# get pc language
- polling data source c# using threads
- how to disable device guard or credential guard vmware
- what function is called just before the a script is ended c#
- iterate through dictionary c#
- decimals not stored in azure tables
- c# type of generic is string
- how to change the title of the console in c#
- computer
- json tiers dot in name c#