solve on vector equation

10 visualizaciones (últimos 30 días)
Michiel Mathijs
Michiel Mathijs el 19 de Dic. de 2019
Editada: David Goodmanson el 21 de Dic. de 2019
Dear
i want to solve a vector equation to find the N vector. The equation is :
eq1 = nt/ni*cross(N,cross(-1*N,cv1))-N*sqrt(1-(nt/ni)^2*dot(cross(N,cv1),cross(N,cv1)))==[1;0;0];
Normal solve yields thre empty arrays>
Thanks in advance
With kind regards
  4 comentarios
darova
darova el 19 de Dic. de 2019
Did you try fsolve?
eq1 = @(N) nt/ni*cross(N,cross(-1*N,cv1))-N*sqrt(1-(nt/ni)^2*dot(cross(N,cv1),cross(N,cv1))) - [1 0 0];
n1 = fsolve(eq1,[1 1 1]);
Michiel Mathijs
Michiel Mathijs el 20 de Dic. de 2019
Yes it does not give the right answer. It gives following message:
No solution found.
fsolve stopped because the relative size of the current step is less than the
value of the step size tolerance, but the vector of function values
is not near zero as measured by the value of the function tolerance.
<stopping criteria details>

Iniciar sesión para comentar.

Respuesta aceptada

darova
darova el 20 de Dic. de 2019
Try this (solution exists not for any s1 vector)
function main
nt = 1;
ni = 2;
s1 = [1 2 2];
s1 = s1/norm(s1);
function y = F(Nx)
p = cross(-Nx,s1);
f = nt/ni*cross(Nx,p) - Nx*sqrt(1-(nt/ni)^2*dot(p,p));
y = f' - [1;0;0];
end
N = fsolve(@F,[1 1 1]);
p = cross(-N,s1);
t = [s1
N*sqrt(1-(nt/ni)^2*dot(p,p))
nt/ni*cross(N,p)];
v0 = zeros(3,1);
quiver3(v0,v0,v0,t(:,1),t(:,2),t(:,3),1) % all vectors together
hold on
quiver3(t(2,1),t(2,2),t(2,3),1,0,0, 1,'r') % vector [1 0 0]
% quiver3(0,0,0,N(1),N(2),N(3),'g')
hold off
text(s1(1),s1(2),s1(3),'s1 vector')
view(0,0)
axis equal
end

Más respuestas (1)

David Goodmanson
David Goodmanson el 21 de Dic. de 2019
Editada: David Goodmanson el 21 de Dic. de 2019
Hi Michiel,
The unit vector N has to lie in the plane defined by s1 and s2. The result for any s1,s2 is
N = s2 - (n1/n2)*s1;
N = N/norm(N);
% have to determine whether N points in +N direction or -N direction
sgn = sign((n1/n2)*dot(s1,s2)-1);
N = sgn*N;
N has to lie in the plane defined by s1,s2 because from the bac-cab rule (letting n1/n2 = n12)
s2 = n12 (N x(-N x s1)) - N sqrt(...)
s2 = n12 (-N (N.s1) + s1) - N sqrt(...)
s2 - n12 s1 = -N ( n12 (N.s1) + sqrt(...) )
const N = s2 -n21 s1
.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by