plot earth shadow(lighting?)

14 views (last 30 days)
Jae-Hee Park
Jae-Hee Park on 30 May 2022
Commented: Jae-Hee Park on 14 Jun 2022
Hi, I want to make Earth plot like below picture.
The point is the borfer of lighting area and shadow area should show clearly like below picture.
But Attatched Code do not show shadow area clearly.
What should I do?
%% Textured 3D Earth example
%
% Ryan Gray
% 8 Sep 2004
% Revised 9 March 2006, 31 Jan 2006, 16 Oct 2013
%% Options
space_color = 'k';
npanels = 180; % Number of globe panels around the equator deg/panel = 360/npanels
alpha = 1; % globe transparency level, 1 = opaque, through 0 = invisible
%GMST0 = []; % Don't set up rotatable globe (ECEF)
GMST0 = 4.89496121282306; % Set up a rotatable globe at J2000.0
% Earth texture image
% Anything imread() will handle, but needs to be a 2:1 unprojected globe
% image.
image_file = 'http://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Land_ocean_ice_2048.jpg/1024px-Land_ocean_ice_2048.jpg';
% Mean spherical earth
erad = 6371008.7714; % equatorial radius (meters)
prad = 6371008.7714; % polar radius (meters)
erot = 7.2921158553e-5; % earth rotation rate (radians/sec)
%% Create figure
figure('Color', space_color);
hold on;
% Turn off the normal axes
set(gca, 'NextPlot','add', 'Visible','off');
axis equal;
axis auto;
% Set initial view
view(0,30);
axis vis3d;
%% Create wireframe globe
% Create a 3D meshgrid of the sphere points using the ellipsoid function
[x, y, z] = ellipsoid(0, 0, 0, erad, erad, prad, npanels);
globe = surf(x, y, -z, 'FaceColor', 'none', 'EdgeColor', 0.5*[1 1 1]);
if ~isempty(GMST0)
hgx = hgtransform;
set(hgx,'Matrix', makehgtform('zrotate',GMST0));
set(globe,'Parent',hgx);
end
%% Texturemap the globe
% Load Earth image for texture map
cdata = imread(image_file);
% Set image as color data (cdata) property, and set face color to indicate
% a texturemap, which Matlab expects to be in cdata. Turn off the mesh edges.
set(globe, 'FaceColor', 'texturemap', 'CData', cdata, 'FaceAlpha', alpha, 'EdgeColor', 'none');
lighting(gca,'flat');
material(gca,"dull");
h= light;
h.Style = 'infinite';
h.Color = 'white';
for az = -50:10:50
lightangle(h,az,0)
pause(.5)
end

Accepted Answer

DGM
DGM on 30 May 2022
You can do a couple things. You can adjust the material properties to increase contrast (reduce ka, boost kd). See this documentation.
What you really need is to adjust the light. I really don't know how to boost the lighting strength other than just stacking lights. Using some local lights might help.
%% Texturemap the globe
% Load Earth image for texture map
cdata = imread(image_file);
% Set image as color data (cdata) property, and set face color to indicate
% a texturemap, which Matlab expects to be in cdata. Turn off the mesh edges.
set(globe, 'FaceColor', 'texturemap', 'CData', cdata, 'FaceAlpha', alpha, 'EdgeColor', 'none');
lighting(gca,'flat');
% adjust material reflectance
material(gca,[0.2 1 0 1 1])
% use multiple lights in the same location
h = gobjects(6,1);
for hk = 1:numel(h)
h(hk) = light('style','infinite','color','w');
end
for az = -50:10:50
for hk = 1:numel(h)
lightangle(h(hk),az,0)
end
pause(.1)
end
This seems like a terribly inelegant solution, but the documentation really feels like a scattered and poorly-crosslinked mess. It's made particularly difficult to search because of the generic function names like "light".
  1 Comment
Jae-Hee Park
Jae-Hee Park on 14 Jun 2022
@DGM There is no way except using lighting? Because in the app designer the color looks diffrence.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!