How can I get all the coordinate points between two points in python? For example: I have a point with the coordinates of x1, y1 and an other with x10, y10. I need all the points between them (in this case for instance x2, y2 ... x9, y9). Huge thanks for your help!
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
"All of them"? There are an infinite number.
You can calculate the slope and intercept of the line between those two points. Knowing those you can calculate the value for y at every value of x you wish using the equation for the line.
This is high school algebra. What's the problem?
Given two points
(x1, y1)
and(x2, y2)
the equation for the line between them is:where
and
If you mean "draw the circle passing between the two points and find all the points inside", I'd calculate the center point as the midpoint of that line and radius equal to half the length of that line. You calculate whether or not a point is inside or outside the circle by determining the distance from the center and comparing it to the radius.
There are an infinite numbers of points both inside and outside the circle. What are you really trying to do here?
Seems you want to generate a list of integer points for the line segment between given points. This problem is solved in computer graphics, for example, using Bresenham algorithm or DDA algo