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)
hold on
quiver3(t(2,1),t(2,2),t(2,3),1,0,0, 1,'r')
hold off
text(s1(1),s1(2),s1(3),'s1 vector')
view(0,0)
axis equal
end
Best Answer