- Tangent to the meridian of the sphere that passes through the point;
- Pointing towards the "south pole", as defined by phi (polar angle) equal to -pi/2?
How to define a vector along the meridional direction?
7 views (last 30 days)
Show older comments
There is a total of 16416 points which can be defined by (x,y,z) in Cartesian coordinates or (theta, phi, r) in spherical coordinates. All of these points are located on the surface of a sphere. For each point, I want to define a vector go through it. The direction of this vector should along the meridional direction of the sphere. Does anyone know how to define 16416 vectors which oriented meridionally? Thanks.
2 Comments
Giovanni Mottola
on 5 Oct 2016
Please clarify your question, as it's not really clear what you mean by meridional direction. Do you mean a vector that is:
Accepted Answer
Giovanni Mottola
on 6 Oct 2016
If you have p=[x, y, z] (coordinates for point p), we need a vector v_merid=[vx, vy, vz] that is tangent to the sphere surface, that is, normal to the radius of the sphere, which joins the sphere centre (I assume it's in C=[0, 0, 0]) to p. As such it must be (p-C).v_merid=0, where . denotes the dot product. This translates to
[x, y, z]*[vx, vy, vz].'==0
in MATLAB syntax. The other conditions are that v_merid and (p-C) have two projections on plane x-y that are aligned (assuming, as seems reasonable, that the North and South pole of your sphere are on the z-axis). Then it must also hold
x/vx==y/vy
We need a third equation to determine the three unknowns vx, vy, vz; I will require that the vector is of unit length, so
vx^2+vy^2+vz^2==1
The system can be solved analytically. The solution is implemented in the following code, where x, y, z are vectors of the same length with the coordinates of your data points.
vx=-(x.*z)./(sqrt(x.^2+y.^2));
vy=-(y.*z)./(sqrt(x.^2+y.^2));
vz=(x.^2+y.^2)./(sqrt(x.^2+y.^2));
Here, for simplicity, I have assumed that the sphere has radius R=1; if this is not the case, divide each vector by R.
The vectors can be plotted on the sphere by the command quiver3, as follows:
quiver3(x, y, z, vx, vy, vz)
The final result (assuming you have already plotted the sphere and the points) is in the following image, where I picked 20 random points on the sphere.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175202/image.bmp)
3 Comments
Giovanni Mottola
on 6 Oct 2016
Hi Jason, I suggest you create a new question. You should maybe specify what do you need by "randomly": do you still want a single angle for all vectors?
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!