c# get every point in a line in matrix
C#
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#:
- Title
- c# max sequence contains no elements
- Category
- C#
- Title
- calculate impact damage + unity
- Category
- C#
- Title
- C# save pdf stream to file
- Category
- C#
- Title
- convert word files to plain text c#
- Category
- C#
- Title
- built in methods to order a list c#
- Category
- C#
- Title
- unity button interactable
- Category
- C#
- Title
- or in unity c#
- Category
- C#
- Title
- never lose focus textbox c#
- Category
- C#
- Title
- c# list tuple
- Category
- C#
- Title
- Unity if object doens't exist
- Category
- C#
- Title
- unity cast float to int
- Category
- C#
- Title
- c# odd even median
- Category
- C#
- Title
- c# set textbox text
- Category
- C#
- Title
- unity rotate object relative to camera
- Category
- C#
- Title
- c# foreach namevaluecollection
- Category
- C#
- Title
- c# generic abstract method
- Category
- C#
- Title
- Unity C# instantiate prefab
- Category
- C#
- Title
- override Microsoft.AspNetCore.Authorization.AuthorizeAttribute
- Category
- C#
- Title
- Move player on planets in unity 2d
- Category
- C#
- Title
- c# LCP
- Category
- C#
- Title
- c# how to initialize an array
- Category
- C#
- Title
- check which activity in focus in android
- Category
- C#
- Title
- unity list
- Category
- C#
- Title
- unity array of child objects
- Category
- C#
- Title
- get random number c#
- Category
- C#
- Title
- c# read all lines from filestream
- Category
- C#
- Title
- c# resize image keep aspect ratio
- Category
- C#
- Title
- c# switct case
- Category
- C#
- Title
- downlaod file and use C#
- Category
- C#
- Title
- optional parameter get request c#
- Category
- C#
- Title
- what is the namespace for textmesh pro
- Category
- C#
- Title
- c# code snippet template
- Category
- C#
- Title
- unity making homing missile
- Category
- C#
- Title
- run async methods within a sync process
- Category
- C#
- Title
- unity get max occurrence in list
- Category
- C#
- Title
- how to name GameObject in c#
- Category
- C#
- Title
- C# extend array
- Category
- C#
- Title
- unity input get axis
- Category
- C#
- Title
- How to get number of months between 2 dates c#
- Category
- C#
- Title
- C# linq mselect
- Category
- C#
- Title
- change partial view based on select asp.net core
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- unity c# get bool from another script
- Category
- C#
- Title
- c# find index element array
- Category
- C#
- Title
- unity set material
- Category
- C#
- Title
- resize image c#
- Category
- C#
- Title
- C# type cast float to string
- Category
- C#
- Title
- native-googlesignin configuration is null!?
- Category
- C#
- Title
- cc# sort list with list if ids
- Category
- C#
- Title
- how to detect if a key is pressed in c#
- Category
- C#
- Title
- idbset sqlquery
- Category
- C#
- Title
- math class C# exponents
- Category
- C#
- Title
- C# .NET Core linq Distinct
- Category
- C#
- Title
- unity up arrow input
- Category
- C#
- Title
- two players one phone unity gamne
- Category
- C#
- Title
- c# throw new exception
- Category
- C#
- Title
- how to make infinite loop in c#
- Category
- C#
- Title
- get query string parameter from string value c#
- Category
- C#
- Title
- c# filter non alphanumeric characters
- Category
- C#
- Title
- uwp file open picker
- Category
- C#
- Title
- string to enum c#
- Category
- C#
- Title
- c sharp check if list contains
- Category
- C#
- Title
- unity cycle children
- Category
- C#
- Title
- inheritance c#
- Category
- C#
- Title
- unity get list length
- Category
- C#
- Title
- increase variable C#
- Category
- C#
- Title
- c# list get sublist
- Category
- C#
- Title
- c# winform remove button border
- Category
- C#
- Title
- iformfile blobclient
- Category
- C#
- Title
- unity serializefield
- Category
- C#
- Title
- c# get index of item in list
- Category
- C#
- Title
- c# empty char
- Category
- C#
- Title
- get random value from list c#
- Category
- C#
- Title
- open udp socket c#
- Category
- C#
- Title
- unity assign button onclick
- Category
- C#
- Title
- c# string replace comma with newline
- Category
- C#
- Title
- Length = '((System.Net.RequestStream)RequestStream).Length' threw an exception of type 'System.NotSupportedException'
- Category
- C#
- Title
- Time delay C# unity
- Category
- C#
- Title
- toggle unity c#
- Category
- C#
- Title
- count the number of notes in a given amount c#
- Category
- C#
- Title
- create a file in the directory of the exe and write to it c#
- Category
- C#
- Title
- if entity.is Transient() Update Mvc 5 c#
- Category
- C#
- Title
- c sharp check if key in dictionary
- Category
- C#
- Title
- condition when a animation finishes in unity
- Category
- C#
- Title
- c# replace string case insensitive
- Category
- C#
- Title
- itext7 pdfwriter outputstream c#
- Category
- C#
- Title
- c# checksum
- Category
- C#
- Title
- unity get child
- Category
- C#
- Title
- unity round
- Category
- C#
- Title
- using mediamanager how to play mp3 files
- Category
- C#
- Title
- ASP select box all states
- Category
- C#
- Title
- leantween sequence
- Category
- C#
- Title
- unity no serializefield
- Category
- C#
- Title
- unity 3d character controller
- Category
- C#
- Title
- how to create a variable in C#
- Category
- C#
- Title
- reference to gameobject in different scene unity
- Category
- C#
- Title
- iterate through xpdictionary devexpress
- Category
- C#
- Title
- c# reverse list
- Category
- C#
- Title
- unity rigidbody constraints
- Category
- C#
- Title
- copy a list C#
- Category
- C#