<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785</link>
    <title>MATLAB Central Newsreader - Plot trajectories on a sphere?</title>
    <description>Feed for thread: Plot trajectories on a sphere?</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 09 Jan 2008 18:58:02 -0500</pubDate>
      <title>Re: Plot trajectories on a sphere?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785#408755</link>
      <author>Charles Cuell</author>
      <description>"Anil Seth" &amp;lt;a.k.seth.nospamplease@sussex.ac.uk&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fm2li8$ntr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I would be VERY grateful for advice.  Basically I want to&lt;br&gt;
&amp;gt; plot an x,y trajectory on the surface of a sphere.  The &lt;br&gt;
data&lt;br&gt;
&amp;gt; I have are in the following form:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x: a vector (N) in [-200,200] &lt;br&gt;
&amp;gt; y: a vector (N) in [-200,200]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; NB these vectors are toroidal in the sense that -201 maps &lt;br&gt;
to&lt;br&gt;
&amp;gt; 199.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What I want:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; plot these trajectories on a sphere of fixed radius (ie &lt;br&gt;
non&lt;br&gt;
&amp;gt; deformed). &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Simple question:  If all this is too much, just tell me &lt;br&gt;
how&lt;br&gt;
&amp;gt; to plot a line on the surface of a sphere!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
If your data vectors, x and y, are already "toroidal", then &lt;br&gt;
I presume that means they are representing angles?  If that &lt;br&gt;
is the case then the x and y are representing points on the &lt;br&gt;
surface of a torus and you need a transformation that takes &lt;br&gt;
points on a torus to points on a sphere. If so, the trouble &lt;br&gt;
is that a sphere is not a torus and there is no nice &lt;br&gt;
transformation.    &lt;br&gt;
&amp;nbsp;&lt;br&gt;
Charles&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 09 Jan 2008 18:27:01 -0500</pubDate>
      <title>Re: Plot trajectories on a sphere?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785#408748</link>
      <author>Roger Stafford</author>
      <description>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message &amp;lt;fm32q1&lt;br&gt;
$rak$1@canopus.cc.umanitoba.ca&amp;gt;...&lt;br&gt;
&amp;gt; In article &amp;lt;fm2ofj$evq$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt; Roger Stafford &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;If you anticipate that x or y &lt;br&gt;
&amp;gt; &amp;gt;will have numbers outside the range you describe, you would first &lt;br&gt;
perform:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; x = mod(x+200,400)-200;&lt;br&gt;
&amp;gt; &amp;gt; y = mod(y+200,400)-200;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;to do your "toroidal" thing.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you have a vector that crosses the boundary, then would not&lt;br&gt;
&amp;gt; taking the mod like that would result in a large jump back rather&lt;br&gt;
&amp;gt; than in smooth crossing of the boundary?&lt;br&gt;
-------&lt;br&gt;
Yes, that worried me too, Walter.  It is to be hoped that in any given &lt;br&gt;
"trajectory" all the points would be shifted by mod in the same way.  I think &lt;br&gt;
we need a lot more clarification from Anil.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 09 Jan 2008 18:12:17 -0500</pubDate>
      <title>Re: Plot trajectories on a sphere?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785#408744</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fm2ofj$evq$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
Roger Stafford &amp;lt;ellieandrogerxyzzy@mindspring.com.invalid&amp;gt; wrote:&lt;br&gt;
&amp;gt;If you anticipate that x or y &lt;br&gt;
&amp;gt;will have numbers outside the range you describe, you would first perform:&lt;br&gt;
&lt;br&gt;
&amp;gt; x = mod(x+200,400)-200;&lt;br&gt;
&amp;gt; y = mod(y+200,400)-200;&lt;br&gt;
&lt;br&gt;
&amp;gt;to do your "toroidal" thing.&lt;br&gt;
&lt;br&gt;
If you have a vector that crosses the boundary, then would not&lt;br&gt;
taking the mod like that would result in a large jump back rather&lt;br&gt;
than in smooth crossing of the boundary?&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;"No one has the right to destroy another person's belief by&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;demanding empirical evidence."                -- Ann Landers&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 09 Jan 2008 15:42:02 -0500</pubDate>
      <title>Re: Plot trajectories on a sphere?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785#408718</link>
      <author>David </author>
      <description>"Anil Seth" &amp;lt;a.k.seth.nospamplease@sussex.ac.uk&amp;gt; wrote in &lt;br&gt;
message &amp;lt;fm2li8$ntr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I would be VERY grateful for advice.  Basically I want to&lt;br&gt;
&amp;gt; plot an x,y trajectory on the surface of a sphere.  The &lt;br&gt;
data&lt;br&gt;
&amp;gt; I have are in the following form:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x: a vector (N) in [-200,200] &lt;br&gt;
&amp;gt; y: a vector (N) in [-200,200]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; NB these vectors are toroidal in the sense that -201 &lt;br&gt;
maps to&lt;br&gt;
&amp;gt; 199.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What I want:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; plot these trajectories on a sphere of fixed radius (ie &lt;br&gt;
non&lt;br&gt;
&amp;gt; deformed). &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Simple question:  If all this is too much, just tell me &lt;br&gt;
how&lt;br&gt;
&amp;gt; to plot a line on the surface of a sphere!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&lt;br&gt;
since i can't figure out what kind of data you really have &lt;br&gt;
from what you wrote above, here is something generic.  &lt;br&gt;
this plots a sphere with the earth topo on it then draws a &lt;br&gt;
3 line trajectory with vectors at each point projected &lt;br&gt;
onto the surface.&lt;br&gt;
&lt;br&gt;
scale=100;&lt;br&gt;
&lt;br&gt;
%plot a sphere with radius scale&lt;br&gt;
load('topo.mat','topo','topomap1');&lt;br&gt;
[X,Y,Z]=sphere(24);&lt;br&gt;
&lt;br&gt;
X=X*scale;&lt;br&gt;
Y=Y*scale;&lt;br&gt;
Z=Z*scale;&lt;br&gt;
&lt;br&gt;
h = surface(X,Y,Z,'FaceColor','texture','CData',topo);&lt;br&gt;
rotate(h,[0 0 1],180)&lt;br&gt;
colormap(topomap1)&lt;br&gt;
hold on&lt;br&gt;
&lt;br&gt;
%made up numbers for trajectory and vectors at 4 points&lt;br&gt;
xt=[0;5;6;10];&lt;br&gt;
vxt=[0;0;1;1];&lt;br&gt;
yt=[5;10;15;16];&lt;br&gt;
vyt=[1;1;0;0];&lt;br&gt;
zt=[100;95;90;85];&lt;br&gt;
vzt=[.1;.1;.1;.1];&lt;br&gt;
&lt;br&gt;
%convert to spherical coords&lt;br&gt;
[T,P,R]=cart2sph(xt,yt,zt);&lt;br&gt;
%project onto surface of sphere by making radius constant&lt;br&gt;
R(:)=scale;&lt;br&gt;
%convert back to cartesian for plotting&lt;br&gt;
[xt,yt,zt]=sph2cart(T,P,R);&lt;br&gt;
&lt;br&gt;
%plot&lt;br&gt;
plot3(xt,yt,zt,'r')&lt;br&gt;
quiver3(xt,yt,zt,vxt,vyt,vzt,1,'y-');&lt;br&gt;
&amp;nbsp;&amp;nbsp;&lt;br&gt;
hold off&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 09 Jan 2008 15:16:03 -0500</pubDate>
      <title>Re: Plot trajectories on a sphere?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785#408714</link>
      <author>Roger Stafford</author>
      <description>"Anil Seth" &amp;lt;a.k.seth.nospamplease@sussex.ac.uk&amp;gt; wrote in message &lt;br&gt;
&amp;lt;fm2li8$ntr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I would be VERY grateful for advice.  Basically I want to&lt;br&gt;
&amp;gt; plot an x,y trajectory on the surface of a sphere.  The data&lt;br&gt;
&amp;gt; I have are in the following form:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x: a vector (N) in [-200,200] &lt;br&gt;
&amp;gt; y: a vector (N) in [-200,200]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; NB these vectors are toroidal in the sense that -201 maps to&lt;br&gt;
&amp;gt; 199.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What I want:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; plot these trajectories on a sphere of fixed radius (ie non&lt;br&gt;
&amp;gt; deformed). &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Simple question:  If all this is too much, just tell me how&lt;br&gt;
&amp;gt; to plot a line on the surface of a sphere!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
--------&lt;br&gt;
&amp;nbsp;&amp;nbsp;I'm not sure what it is that puzzles you, Anil.  If you anticipate that x or y &lt;br&gt;
will have numbers outside the range you describe, you would first perform:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;x = mod(x+200,400)-200;&lt;br&gt;
&amp;nbsp;y = mod(y+200,400)-200;&lt;br&gt;
&lt;br&gt;
to do your "toroidal" thing.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;You can find the corresponding z vector from:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;z = z0 + sqrt(r^2-(x-x0).^2-(y-y0).^2);&lt;br&gt;
&lt;br&gt;
for the upper surface (subtract the square root for the lower surface) of the &lt;br&gt;
sphere with radius r and center at (x0,y0,z0).  (Any z's that are imaginary &lt;br&gt;
would be points that don't project onto the sphere.)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;If your successive points in the (x,y,z) vectors are far apart and you wish to &lt;br&gt;
connect them with a great circle arc on the sphere rather than a straight line, &lt;br&gt;
that can be done in terms of cross products of three-dimensional vectors.  &lt;br&gt;
Let me know if this latter is your actual problem and I can give the necessary &lt;br&gt;
formula.&lt;br&gt;
&lt;br&gt;
Roger Stafford&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 09 Jan 2008 14:26:16 -0500</pubDate>
      <title>Plot trajectories on a sphere?</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/161785#408709</link>
      <author>Anil Seth</author>
      <description>I would be VERY grateful for advice.  Basically I want to&lt;br&gt;
plot an x,y trajectory on the surface of a sphere.  The data&lt;br&gt;
I have are in the following form:&lt;br&gt;
&lt;br&gt;
x: a vector (N) in [-200,200] &lt;br&gt;
y: a vector (N) in [-200,200]&lt;br&gt;
&lt;br&gt;
NB these vectors are toroidal in the sense that -201 maps to&lt;br&gt;
199.&lt;br&gt;
&lt;br&gt;
What I want:&lt;br&gt;
&lt;br&gt;
plot these trajectories on a sphere of fixed radius (ie non&lt;br&gt;
deformed). &lt;br&gt;
&lt;br&gt;
Simple question:  If all this is too much, just tell me how&lt;br&gt;
to plot a line on the surface of a sphere!&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
