フィルターのクリア

High order equation Solving

2 ビュー (過去 30 日間)
Jack_111
Jack_111 2013 年 10 月 11 日
コメント済み: Walter Roberson 2013 年 10 月 14 日
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
Walter Roberson
Walter Roberson 2013 年 10 月 14 日
double(Solution)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by