How can I make the Earth rotate around it's axis in matlab?

5 ビュー (過去 30 日間)
Alexandru Lapusneanu
Alexandru Lapusneanu 2018 年 2 月 25 日
コメント済み: David Goodmanson 2018 年 3 月 2 日
So I want to represent the Earth rotating for a number of seconds from a tspan knowing that a full rotation happens in 86160 seconds. It means that for 239.33 seconds , the Earth rotates with a degree. The problem is that I don t know how to use the rotate command in a right way. This is the code:
tspan=[0 :72000];
[X,Y,Z]=sphere(50);
R=6400000;
earth = imread('earth.jpg');
globe= surf(-X*R,Y*R,-Z*R);
image_file='earth.jpg';
cdata = imread(image_file);
set(globe, 'FaceColor', 'texturemap', 'CData', cdata, 'EdgeColor', 'none');
set(gcf,'Color','k')
set(gca, 'visible', 'off')
axis equal
view (90,0)
rotating=1; % 1 degree ever 239.33 seconds from tspan
rotate(earth, [0 1 0],1) % test to see if it's working

採用された回答

David Goodmanson
David Goodmanson 2018 年 2 月 25 日
編集済み: David Goodmanson 2018 年 2 月 26 日
Hi Alexandru,
MODIFIED answer
I used a jpg of my own and reproduced your code, eliminating some lines that were not in use. It works really well. I am not sure what you mean by 'doesn't stay on fixed axis, moves around it'. When I run this, the globe stays in place. I am using [0 0 1] instead of [0 1 0] so that the globe rotates about the north pole. With [0 1 0] the globe is rotating about an unusual axis, but it is still staying in place and rotating about its center of mass.
[X,Y,Z]=sphere(50);
R=6400000;
globe= surf(-X*R,Y*R,-Z*R);
cdata = imread('chilis.jpg');
set(globe, 'FaceColor', 'texturemap', 'CData', cdata, 'EdgeColor', 'none');
set(gcf,'Color','k')
set(gca, 'visible', 'off')
axis equal
view (90,0)
rotate(earth, [0 0 1],1) % test to see if it's working
  12 件のコメント
Alexandru Lapusneanu
Alexandru Lapusneanu 2018 年 3 月 2 日
I figured it out , after all. The code it's working, but the problem is that the axis are rescaling after the orbit is being displayed as growing from values that are close to the Earth's radius, when it's at perigee, to bigger values at apogee.
David Goodmanson
David Goodmanson 2018 年 3 月 2 日
just a matter of time before you solved it.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMap Display についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by