High order equation Solving

1 次查看(过去 30 天)
I am doing ray tracing and I have to make intersection between the ray and polynomial so I got the following equation and I have to solve it for t.
A(21).*(Y.^5) + (A(20).*(Y.^4)).*X + A(19).*(Y.^4) + (A(18).*(Y.^3)).*(X.^2) + (A(17).*(Y.^3)).*X + A(16).*(Y.^3) + (A(15).*(Y.^2)).*(X.^3) + (A(14).*(Y.^2)).*(X.^2) + (A(13).*(Y.^2)).*X + A(12).*(Y.^2) + (A(11).*(Y)).*(X.^4) + (A(10).*Y).*(X.^3) + (A(9).*Y).*(X.^2) + (A(8).*Y).*(X) + (A(7).*Y) + A(6).*(X.^5) + A(5).*(X.^4) + A(4).*(X.^3) + A(3).*(X.^2) + A(2).*X + A(1) - Z = 0;*
While:
X = (px +t*dx);
Y = (py +t*dy);
Z = (pz +t*dz);
so I want to get t in respect to the other variables. ( I have all the other variables but I don't know how to calculate it )
Please support Many thanks in advance

采纳的回答

sixwwwwww
sixwwwwww 2013-10-12
Dear Yaman, Here is the solution of your problem in symbolic form:
syms X Y Z p x y z t dx dy dz
A = sym('A%d', [1 21]);
X = p * x + t * dx;
Y = p * y + t * dy;
Z = p * z + t * dz;
equation = A(21) * Y^5 + (A(20) * Y^4) * X + A(19)* Y^4 + (A(18) * Y^3) * X^2 + (A(17) * Y^3) * X + A(16) * Y^3 + (A(15) * Y^2) * X^3 + ...
(A(14) * Y^2) * X^2 + (A(13) * Y^2) * X + A(12) * Y^2 + (A(11) * Y) * X^4 + (A(10) * Y) * X^3 + (A(9) * Y) * X^2 + (A(8) * Y) *X + A(7) * Y +...
A(6) * X^5 + A(5) * X^4 + A(4) * X^3 + A(3) * X^2 + A(2) * X + A(1) - Z;
Solution = solve(equation == 0, t);
Now if you put your know values of A(1)...A(21) and p, x, y, z, dx, dy, dz using "subs" function in "equation" then use last statement
Solution = solve(equation == 0, t);
then you will get your desired solution for "t". For information about "subs" see http://www.mathworks.com/help/symbolic/subs.html . Good luck!
  2 个评论
Jack_111
Jack_111 2013-10-14
But the answer still in the Subbolic way and I want it in the double format or float

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by