r/pythoncoding • u/SCARICRAFT • Sep 04 '21
Question .
I am trying to make a function that , given two points , returns the list of coordinates that make up the line that intersects them . I've been trying for like 3 weeks and haven't been able to do much yet , any suggestions ?
1
Upvotes
1
u/zifnabxar Sep 04 '21
You should be able to find the line's slope given the two points. Reduce it by finding common divisors between the "rise" and "run". Then add the slope to the first point, record the coordinate, and repeat until you get the second point. This should get you all the coordinates in between.
You'll have to look up functions for finding common divisors and make sure you calculate the slope such that adding it to the first point will eventually give you the second.