I have a MATLAB code that plots a 3D sphere using:
[xs,ys,zs] = sphere(10);
surface = surf(350*zs+1000,350*ys,350*xs);
I also have a line that represents the normal between three points (labeled P0, P1, P2) on a plane, which is plotted from the middle-point between all three points:
P0 = [tz1,ty1,tx1]; P1 = [tz2,ty2,tx2]; P2 = [tz3,ty3,tx3];
Pm = mean([P0;P1;P2]);
normal = cross(P0-P1,P0-P2);
cn = normal + Pm;
normal_vector = plot3([Pm(1) cn(1)],[Pm(2) cn(2)],[Pm(3) cn(3)],'k--');
What I am trying to do is find the coordinates of the point of intersection between the line "normal_vector" and the sphere "surface".
This is what the plot looks like:
The points P0, P1 and P2 are shown as coloured circles and are always inside the sphere, so their normal is always showing 'outwards' through the surface of the sphere.
Thank you in advance!