High order equation Solving

조회 수: 1 (최근 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 CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by