Sympy:如何计算 3D 线上点的 t 值
Sympy: How to calculate the t value for a point on a 3D Line
如何使用 sympy 求解直线或线段上特定点的 t 值?
p1 = sympy.Point3D(0,0,0)
p2 = sympy.Point3D(1,1,1)
p3 = sympy.Point3D(0.5,0.5,0.5)
lineSegment = sympy.Segment(p1,p2)
eqnV = lineSegment.arbitrary_point()
if lineSegment.contains(p3):
t = SolveForT(lineSegment, p3)
您可以获得坐标方程列表并将它们传递给 sympy 的求解函数:
In [112]: solve((lineSegment.arbitrary_point() - p3).coordinates)
Out[112]: {t: 1/2}
如何使用 sympy 求解直线或线段上特定点的 t 值?
p1 = sympy.Point3D(0,0,0)
p2 = sympy.Point3D(1,1,1)
p3 = sympy.Point3D(0.5,0.5,0.5)
lineSegment = sympy.Segment(p1,p2)
eqnV = lineSegment.arbitrary_point()
if lineSegment.contains(p3):
t = SolveForT(lineSegment, p3)
您可以获得坐标方程列表并将它们传递给 sympy 的求解函数:
In [112]: solve((lineSegment.arbitrary_point() - p3).coordinates)
Out[112]: {t: 1/2}