如何在python中计算两点之间的线的坐标? [英] How to calculate the coordinates of the line between two points in python?

查看:1089
本文介绍了如何在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?

这篇关于如何在python中计算两点之间的线的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆