如何求解符号非线性矢量方程? (Matlab或其他)
我试图找到这个符号非线性向量方程的解:
P = a*(V0*t+P0) + b*(V1*t+P1) + (1-a-b)*(V2*t+P2) for a, b and t
其中 P、V0、V1、V2、P0、P1、P2 是已知的 3d 向量。
我尝试在 Matlab 中这样做:
P = sym('P', [3,1])
P0 = sym('P0', [3,1])
P1 = sym('P1', [3,1])
P2 = sym('P2', [3,1])
V0 = sym('V0', [3,1])
V1 = sym('V1', [3,1])
V2 = sym('V2', [3,1])
syms a b t
F = a*(V0*t+P0) + b*(V1*t+P1) + (1-a-b)*(V2*t+P2) - P
solve(F,a,b,t)
我发现
Warning: Explicit solution could not be found.
我开始没有办法解决它,这不是我尝试的第一个数学包。
有趣的是,这个方程有一个简单的几何解释。如果您想象点 P0-P2 是三角形的顶点,V0-V2 大致是顶点法线,点 P 位于三角形上方,则对于包含点 P 的三角形,其三个顶点位于三条射线上 (V *t+P),共享相同的参数t值。 a、b 和 (1-ab) 成为点 P 的重心坐标。
因此,如果情况不是退化的,则 t 应该只有一个明确定义的解。
I'm trying to find a solution to this symbolic non-linear vector equation:
P = a*(V0*t+P0) + b*(V1*t+P1) + (1-a-b)*(V2*t+P2) for a, b and t
where P, V0, V1, V2, P0, P1, P2 are known 3d vectors.
I attempted to do that in Matlab like this:
P = sym('P', [3,1])
P0 = sym('P0', [3,1])
P1 = sym('P1', [3,1])
P2 = sym('P2', [3,1])
V0 = sym('V0', [3,1])
V1 = sym('V1', [3,1])
V2 = sym('V2', [3,1])
syms a b t
F = a*(V0*t+P0) + b*(V1*t+P1) + (1-a-b)*(V2*t+P2) - P
solve(F,a,b,t)
I get
Warning: Explicit solution could not be found.
I'm starting to run out of ideas how to solve it, this isn't the first math package I tried.
The interesting bit is that this equation has a simple geometrical interpretation. If you imagine that points P0-P2 are vertices of a triangle, V0-V2 are roughly vertex normals and point P lies above the triangle, then the equation is satisfied for a triangle containing point P with it's three vertices on the three rays (V*t+P), sharing the same parameter t value. a, b and (1-a-b) become the barycentric coordinates of the point P.
So if the case is not degenerate, there should be only one well defined solution for t.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
作为符号方程,该方程有 3 个变量,因此不可能有单一解。
假设您为 b 和 t 选择任意值。然后在几乎所有情况下你都可以求解 a,因此你会得到许多不同的解决方案。
如果您想从几何角度思考,请想象 V0 和 V1 指向 (P0,P1,P2) 三角形的上半空间,但 V2 指向下半空间。另外,V0、V1 垂直于三角形平面,V0 和 V1 是单位向量。
现在,如果您有一个固定在点 P 的平面,该平面与光线 P0+t*V0 和 P1+t*V1 相交于三角形上方相同的距离,则可以移动该平面,使其保持固定在 P 处并以相同的距离相交两条射线。这只是选择 V2 的问题,使得与该平面的交点以相同的速度移动,因此它将对应于相同的 t,从而为您提供无限多个解决方案。
另一个例子是,如果所有 V0-V2 与三角形 P0、P1、P2 共线。然后你很容易得到任何 t 的解决方案。
所以你需要更多的方程来象征性地解决这个问题。
As symbolic equation, this one has 3 variables, so there is no way to have a single solution.
Imagine you pick any values for say b and t. Then in almost all cases you can solve for a, so you get many different solutions.
If you want to think geometrically, imagine that V0 and V1 point in the upper half-space regarding the (P0,P1,P2) triangle, but V2 point in the lower. Also V0,V1 are perpendicular to the plane of the triangle and V0 and V1 are unit vectors.
Now if you have a plane pinned at the point P, which intersects the rays P0+t*V0 and P1+t*V1 at the same distance above the triangle, you can move the plane in such a way that it stays pinned at P and intersecting the two rays at the same distance. It's only a matter of having had picked V2 in such a way that the point of intersection with this plane moves at the same velocity, so it will correspond to the same t, thus giving you infinitely many solutions.
Another example would be if all V0-V2 were colinear with the triangle P0,P1,P2. Then you trivially get a solution for any t.
So you need more equations to solve this symbolically.