"Anil Seth" <a.k.seth.nospamplease@sussex.ac.uk> wrote in message
<fm2li8$ntr$1@fred.mathworks.com>...
> I would be VERY grateful for advice. Basically I want to
> plot an x,y trajectory on the surface of a sphere. The data
> I have are in the following form:
>
> x: a vector (N) in [-200,200]
> y: a vector (N) in [-200,200]
>
> NB these vectors are toroidal in the sense that -201 maps to
> 199.
>
> What I want:
>
> plot these trajectories on a sphere of fixed radius (ie non
> deformed).
>
> Simple question: If all this is too much, just tell me how
> to plot a line on the surface of a sphere!
>
> Thanks!
>
> Thanks
--------
I'm not sure what it is that puzzles you, Anil. If you anticipate that x or y
will have numbers outside the range you describe, you would first perform:
x = mod(x+200,400)-200;
y = mod(y+200,400)-200;
to do your "toroidal" thing.
You can find the corresponding z vector from:
z = z0 + sqrt(r^2-(x-x0).^2-(y-y0).^2);
for the upper surface (subtract the square root for the lower surface) of the
sphere with radius r and center at (x0,y0,z0). (Any z's that are imaginary
would be points that don't project onto the sphere.)
If your successive points in the (x,y,z) vectors are far apart and you wish to
connect them with a great circle arc on the sphere rather than a straight line,
that can be done in terms of cross products of three-dimensional vectors.
Let me know if this latter is your actual problem and I can give the necessary
formula.
"Anil Seth" <a.k.seth.nospamplease@sussex.ac.uk> wrote in
message <fm2li8$ntr$1@fred.mathworks.com>...
> I would be VERY grateful for advice. Basically I want to
> plot an x,y trajectory on the surface of a sphere. The
data
> I have are in the following form:
>
> x: a vector (N) in [-200,200]
> y: a vector (N) in [-200,200]
>
> NB these vectors are toroidal in the sense that -201
maps to
> 199.
>
> What I want:
>
> plot these trajectories on a sphere of fixed radius (ie
non
> deformed).
>
> Simple question: If all this is too much, just tell me
how
> to plot a line on the surface of a sphere!
>
> Thanks!
>
> Thanks
since i can't figure out what kind of data you really have
from what you wrote above, here is something generic.
this plots a sphere with the earth topo on it then draws a
3 line trajectory with vectors at each point projected
onto the surface.
scale=100;
%plot a sphere with radius scale
load('topo.mat','topo','topomap1');
[X,Y,Z]=sphere(24);
X=X*scale;
Y=Y*scale;
Z=Z*scale;
h = surface(X,Y,Z,'FaceColor','texture','CData',topo);
rotate(h,[0 0 1],180)
colormap(topomap1)
hold on
%made up numbers for trajectory and vectors at 4 points
xt=[0;5;6;10];
vxt=[0;0;1;1];
yt=[5;10;15;16];
vyt=[1;1;0;0];
zt=[100;95;90;85];
vzt=[.1;.1;.1;.1];
%convert to spherical coords
[T,P,R]=cart2sph(xt,yt,zt);
%project onto surface of sphere by making radius constant
R(:)=scale;
%convert back to cartesian for plotting
[xt,yt,zt]=sph2cart(T,P,R);
In article <fm2ofj$evq$1@fred.mathworks.com>,
Roger Stafford <ellieandrogerxyzzy@mindspring.com.invalid> wrote:
>If you anticipate that x or y
>will have numbers outside the range you describe, you would first perform:
> x = mod(x+200,400)-200;
> y = mod(y+200,400)-200;
>to do your "toroidal" thing.
If you have a vector that crosses the boundary, then would not
taking the mod like that would result in a large jump back rather
than in smooth crossing of the boundary?
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message <fm32q1
$rak$1@canopus.cc.umanitoba.ca>...
> In article <fm2ofj$evq$1@fred.mathworks.com>,
> Roger Stafford <ellieandrogerxyzzy@mindspring.com.invalid> wrote:
> >If you anticipate that x or y
> >will have numbers outside the range you describe, you would first
perform:
>
> > x = mod(x+200,400)-200;
> > y = mod(y+200,400)-200;
>
> >to do your "toroidal" thing.
>
> If you have a vector that crosses the boundary, then would not
> taking the mod like that would result in a large jump back rather
> than in smooth crossing of the boundary?
-------
Yes, that worried me too, Walter. It is to be hoped that in any given
"trajectory" all the points would be shifted by mod in the same way. I think
we need a lot more clarification from Anil.
"Anil Seth" <a.k.seth.nospamplease@sussex.ac.uk> wrote in
message <fm2li8$ntr$1@fred.mathworks.com>...
> I would be VERY grateful for advice. Basically I want to
> plot an x,y trajectory on the surface of a sphere. The
data
> I have are in the following form:
>
> x: a vector (N) in [-200,200]
> y: a vector (N) in [-200,200]
>
> NB these vectors are toroidal in the sense that -201 maps
to
> 199.
>
> What I want:
>
> plot these trajectories on a sphere of fixed radius (ie
non
> deformed).
>
> Simple question: If all this is too much, just tell me
how
> to plot a line on the surface of a sphere!
>
> Thanks!
>
> Thanks
If your data vectors, x and y, are already "toroidal", then
I presume that means they are representing angles? If that
is the case then the x and y are representing points on the
surface of a torus and you need a transformation that takes
points on a torus to points on a sphere. If so, the trouble
is that a sphere is not a torus and there is no nice
transformation.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.