Filter löschen
Filter löschen

How to define a vector along the meridional direction?

11 Ansichten (letzte 30 Tage)
Yi Hua
Yi Hua am 5 Okt. 2016
Kommentiert: Yi Hua am 6 Okt. 2016
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 Kommentare
Giovanni Mottola
Giovanni Mottola am 5 Okt. 2016
Please clarify your question, as it's not really clear what you mean by meridional direction. Do you mean a vector that is:
  • 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?
Yi Hua
Yi Hua am 6 Okt. 2016
Hello Giovanni,
Thank you for your reply and sorry for my carelessness. You are correct. The vector is tangent to the meridian of the sphere that passes through the point. And the vector can point towards either the "south pole" or the "north pole". Just make sure that the directions of all the vectors are consistent. For example, all of them are pointing towards the "south pole" or all of them are pointing towards the "north pole". Thanks again.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Giovanni Mottola
Giovanni Mottola am 6 Okt. 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.
  3 Kommentare
Giovanni Mottola
Giovanni Mottola am 6 Okt. 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?
Yi Hua
Yi Hua am 6 Okt. 2016
Hello Giovanni,
You are exactly correct. I want a single angle for all vectors. I will create a new question as you suggested. Thanks again.
Jason

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by