solve on vector equation

10 次查看(过去 30 天)
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 个评论
darova
darova 2019-12-19
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 2019-12-20
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>

请先登录,再进行评论。

采纳的回答

darova
darova 2019-12-20
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

更多回答(1 个)

David Goodmanson
David Goodmanson 2019-12-21
编辑:David Goodmanson 2019-12-21
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
.

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by