如何在python中计算两点之间的线的坐标?

问题描述:

如何获取python中两个点之间的所有坐标点? 例如:我有一个坐标为x1,y1的点,另一个坐标为x10,y10.我需要它们之间的所有点(在这种情况下,例如x2,y2 ... x9,y9).非常感谢您的帮助!

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!

全部"?有无数个.

您可以计算这两点之间的直线的斜率和截距.知道了这些之后,您可以使用直线方程式来计算每个x值的y值.

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?

给出两个点(x1, y1)(x2, y2),它们之间的线的等式是:

Given two points (x1, y1) and (x2, y2) the equation for the line between them is:

y = m*x + b

其中

m = slope = (y1-y2)/(x1-x2)

b = y-intercept = (x1*y2 - x2*y1)/(x1-x2)

如果您的意思是画出在两点之间通过的圆并找到其中的所有点",我将计算中心点为该线的中点,半径等于该线长度的一半.通过确定到中心的距离并将其与半径进行比较,可以计算出点是在圆的内部还是外部.

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?