Effacer les filtres
Effacer les filtres

Normal vector to surface in a specific point

12 vues (au cours des 30 derniers jours)
Alessandro
Alessandro le 26 Mai 2014
Hi to all!
I've some problems with my code...I'm working on a code where considering a surface z=f(x,y)and a cutting plane the code have to calculate and plot: - the equation of the curve obtained by the intersection of the plane and the surface - the minimum point - the tangent plane to the surface in the minimum point - the normal vector to the surface in the minimum point
I would like to do all the procedures with symbolic expressions...here is my code:
clc
close all
clear all
a=0;
b=0;
c=1
syms x y z x1 y1 z1 t
f(x,y)=2*(x)^2-(y)^2 %surface
f2=a*x+b*y+c %plane
f3=f(x, f2) %trajectory
xt=x
yt=f2
zt=f3
dy=diff(yt,x)
dz=diff(zt,x)
X=solve(dz)
Y=subs(yt, x, X)
Z=subs(zt, x, X)
P=double ([X Y Z])
g = z-f;
subs(g,[x,y,z],[X,Y,Z])
gradg=jacobian(g, [x,y,z])
grad1=gradient(g)
planenormal=subs(gradg, [x,y,z], [X,Y,Z])
realdot = @(u, v) u*transpose(v);
planeq = realdot(planenormal, [x-X,y-Y,z-Z])
planefun=solve(planeq,z)
grad_point=subs(gradg, [x,y],[X,Y])
grad_point_arr =double((grad_point))
norm=[X+grad_point_arr(1)*t, Y+grad_point_arr(2)*t, Z+grad_point_arr(3)*t]
view(74,34)
hold on
ezsurf(x,y,f,[-10,10,-10,10])
ezsurf(x,f2,z,[-10,10,-10,10])
ezplot3 (x,yt,zt,[-10,10,-10,10])
scatter3(X,Y,Z, 'MarkerEdgeColor','k','MarkerFaceColor',[0 .75 .75])
ezplot3(norm(1), norm(2), norm(3))
ezsurf(planefun)
figure(2)
view(74,34)
hold on
ezplot3 (x,f2,f3,[-10,10,-10,10])
scatter3(X,Y,Z, 'MarkerEdgeColor','k','MarkerFaceColor',[0 .75 .75])
ezplot3(norm(1), norm(2), norm(3))
ezsurf(planefun)
The file works but the normal vector to the surface looks wrong....
Thanks!!!!!

Réponses (1)

Semiha YILMAZER
Semiha YILMAZER le 12 Oct 2021

Community Treasure Hunt

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

Start Hunting!

Translated by