Component of a vector parallel with a spherical surface

2 visualizaciones (últimos 30 días)
Hi, I have a coded a function that (using quiver3) produces vectors on the surface of hemisphere. However, the component of the vector that interests me is the component that lies parallel to tangent of the surface of the sphere. I have also plotted the tangent vector that points along the sphere using gradient and the quiver3 function. Here is my code:
if trueR=22; phi=linspace(0,pi,50); theta=linspace(-pi/2,pi/2,50);
[phi,theta]=meshgrid(phi,theta);
X=R*sin(phi).*cos(theta); Y=R*sin(phi).*sin(theta); Z=R*cos(phi);
k=50; T=Z./R;
%U=3*k*Z.*sin(acos(T))./R.^4; %mag field in x
%V=3*k*Z.*sin(acos(T))./R.^4; %mag field in y
%W=2*k*((3*Z.^2 ./ R.^2)-1)./R.^3; % mag field in z %magnetic field function
U=3*k.*sin(theta).*cos(theta).*cos(phi).*R.^-3
V=3*k.*sin(theta).*cos(theta).*sin(phi).*R.^-3
W=3*k*(((cos(theta)).^2)-1./3).*R^-3
quiver3(X,Y,Z,U,V,W,1)% no defines arrow length, other define direction, defines arrow direction (u,v,w) at point (x,y,z)
hold on
dx=gradient(X)
dy=gradient(Y)
dz=gradient(Z)
quiver3(X,Y,Z,dx,dy,dz)
axis equal
% code
end
I now want to perform a dot product of these two vector at each point on my sphere to produce a 3D image of how the tangential component of the original function varies throughout the surface of the sphere.
To do this I tried to create 3 more vectors that corresponded to the dot product of U and X, V and Y and W and Z and then use the quiver3 function to display them.
if true
A=dot(X,dx)
B=dot(Y,dy)
C=dot(Z,dz)
quiver3(X,Y,Z,A,B,C)
% code
Which has not worked, any suggestions would be appreciated. Thanks John

Respuesta aceptada

Venkatachala Sarma
Venkatachala Sarma el 12 de En. de 2016
Hi,
I am assuming that you would like to plot in 3D, components of the magnetic field that are parallel to the tangent of a sphere.
As a first step, you have created a plot of the magnetic field. As a second step the gradient plot was done which clearly shows the tangents at various points on the surface of the sphere.
As a third step, you have identified the dot product of the point and its gradient. There are two issues.
1. You have an array of vectors 2. The dot product of the points and its gradient doesn't give the necessary angle between the magnetic field and the gradient.
So since an array of vectors are under consideration, the 'dot' function doesn't work directly for the dot product. But it has to be manually done for vectors.
If you have two vectors say, a = a1x+a2y+a3z and b = b1x+b2y+b3z, then a.b = (a1*b1)+(a2*b2)+(a3*b3). Now extrapolate it considering the coefficients as matrices. So in your code,
A = U.*dx; B = V.*dy; C = W.*dz;
Finally adding them would give the dot product.
k = A+B+C;
Now we have the dot product which gives us the angle information between the magnetic field and the gradient (the surface of the sphere). In order to find the components of the magnetic field along the surface of the sphere, dot product will not be sufficient but the projection of magnetic field vector on the gradient vector has to be found.
So if a and b are the vectors as shown above, then projection of a on be can be written as,
projaonb = dot(a,b)*unitVector(b) = dot(a,b)* b / b.
So implementing it here for this problem.
k1 = k./sqrt(dx.*dx + dy.*dy + dz.*dz); projx = k1.*dx; projy = k1.*dy; projz = k1.*dz;
quiver3(X, Y, Z, projx, projy, projz);
Now you should possibly see the components of magnetic field vector along the tangent vectors.
-Venkatachala Sarma
  1 comentario
John Draper
John Draper el 12 de En. de 2016
I have tried this and get a nice figure that matches my expectations of what I set out to accomplish. Thanks for your help - this answer must have taken you a while! John.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by