在一个3D空间,已知两个点的坐标(x1,y1,z1)和(x2,y2,z2)。那么这两点确定一条直线
那么,怎么求这直线上一个点呢?比如z=c的这个点
具体空间几何的解决其实会,主要是想看看
1. Python可以怎么优雅的解决这个问题?
2. 有没有相关的立体几何建模、计算的包(lib)?因为还有相关的一些问题想要解决。这个算是抛砖引玉了
3. 如果Python不是很适合解决这类问题,那什么语言更为何时?
像http://stackoverflow.com/questions/1076778/good-geometry-library-in-py...
提到的,都是2D的包,没法派上用场
I think it’s better to solve the problem if you convert it into a vector
If you get the vector (x2-x1, y2-y1, z2-z1), where a=x2-x1; b=y2-y1; c=z2-z1.
Then you can get the equation:
x = x1 + at
y = y1 + bt
z = z1 + ct
In this case, you can write a very simple method in python: getPoint(t).
For any t, the corresponding point on the line can be obtained.
If the space geometry you are talking about refers to the analytical formula x+y+z=0, then there is actually a more elegant solution tool called vector. . Like space geometry, it should also belong to the category of high school, and compared with simple analytical expressions, the expression method of vector plus point has an indescribable elegance. .
There is a scientific library called numpy and a derivative version called scipy. .
http://www.numpy.org
Reminds me of high school knowledge,
I haven't written anything about it before, so I'm just throwing it out there. .
In fact, it is not difficult to write and judge things like vectors yourself. .