File Exchange

image thumbnail

3D Visualization of SUN, EARTH and Moon

version 1.0 (1.17 MB) by

3D Visualization of SUN, EARTH and Moon

3 Ratings



View License

Function SSEM displays 3D Visualization of SUN, EARTH and Moon with two option i.e. with actual data and without actual data just for fun.

SSEM('fun'); just for fun.
SSEM('actual'); For actual viewing.

Physics has been kept simple.

I've created this just for fun and to have a look about graphics capabilities of MATLAB. Any user can use and modify it and have fun.

At starting ain't able to rotate EARTH and MOON on its axis so if any one can do it I'll appreciate it.

Hope you'll enjoy it.

Comments and Ratings (9)

Greeting Jonathan Pound-Espericueta that's wonderful.
Would love to watch it...why don't you submit it...

Hello, Ashish Meshram! I edited the code to allow for Mars. The orbital plane of Mars is inclined to that of Earths as well.

Hi Jonathan Pound-Espericueta

Right now SSEM is implemented only for SUN, EARTH, and MOON.
But no doubt it can be extended to all. Its upto you. And I haven't been giving time to it. I'll appreciate if you can do it.

How would I go about adding another planet to this code such as Mars? Is the SSEM function defined only for the Sun, Earth & Moon?



Happened to come across your submission; What you did was really cool. BTW, the reason why EARTH and MOON don't rotate is because in every iteration of the loop, their positions are calculated again from scratch(e.g. set(HEARTH,'xdata',xEarth(k) + Rm(2)*X...). This effectively resets the 'rotation angle' back to 0. Therefore, instead of specifying a fixed angle, you must use a number that grows as iteration progresses. For instance:

rotate(HEARTH,[0,0,1],2*k,[xEarth(k) yEarth(k) zEarth(k)]);

Also, I suggest you make 'fun' a default parameter, since this is the only working parameter for now.

Thanks Dr. Jens Koopmann, for appreciation. I hope you enjoyed it.


I like your program. Initially I had problem to get it to run. There is a command called im2double -> I replaced it with double and it worked fine

Thanks for sharing.

Ain't sure why ain't able to rotate EARTH and MOON on its own axis as mentioned on line 182 and 193...
Please any one can help me on it...

Run the following command on your command window and enjoy the view by using your mouse when rotate option is enabeled


MATLAB Release
MATLAB 7.14 (R2012a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video