File Exchange Pick of the Week

April 19th, 2007

Earth and moon visualization

This week’s pick comes from two of my colleagues in the UK, Sam and Marta. This is a cool visualization of the Earth and its moon at the proper ratio, but not the proper distance apart. The code is very simple, and one thing I liked about it is how they were able to drape real satellite imagery over the spheres:

topo=imread('earth_lights_small.jpg');
topoud=flipdim(topo,1);

set(s,’facecolor’,'texture’);
set(s,’cdata’, im2double(topoud));

This is a nice technique for making visualizations more realistic and appealing.

nightonearthscreenshot.png

Also, notice that they added a quick GUI button to the figure window with one command:

u=uicontrol('style', 'togglebutton', 'value', false, 'string', 'Exit');

They then wait for this button to be pressed so that they can close the window:

while ~get(u, 'value')
rotate(s,[0,0,1],1,[0,0,0]);
rotate(s2,[0,0,1],0.0357,[0,0,0]);
% camorbit(15,0)
pause(0.1)
end
close(f)

While they are waiting for the user to click the button, they keep rotating the spheres. You can also see some commented out lines of code that are likely to be of interest to people that want to further modify the code later.

[note: Post updated April 23rd to add link to original code. Oops!]

2 Responses to “Earth and moon visualization”

  1. Vincent Noel replied on :

    I may be dense, but I don’t see the link to the actual code ;-)

  2. Seth Popinchalk replied on :

    With a quick search of the exchange, I found the files here:

    http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=14632

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.