MATLAB Creating Graphical User Interfaces

(Barry) #1
Animation with Slider Controls in GUIDE

Uipanel

Axes

rotate
xform

globe
surface

graticule
surface

Light

tilt
xform

Inserted
objects

HG Hierarchy for the Example

The tilt transform applies a rotation about the x-axis of 0.5091 radians (equal to 23.44
degrees, the inclination of the Earth's axis of rotation). The rotate transform initially has
a default identity matrix. The spinstopbutton_Callback subsequently updates the
matrix to rotate about the z-axis by 0.01745329252 radians (1 degree) per iteration, using
the following code:


az = az + 0.01745329252;
set(hgrotate,'Matrix',makehgtform('zrotate',az));
drawnow % Refresh the screen


Light the Globe and Shift the Light Source


A light object illuminates the globe, initially from the left. Two sliders control the
light's position, which you can manipulate whether the globe is standing still or rotating.
The light is a child of the axes, so is not affected by either of the hgtransforms. The call
to light uses no parameters other than its altitude and an azimuth:


hlight = camlight(0,0);


After creating the light, the axes1_CreateFcn adds some handles and data that other
callbacks need to the handles structure:

Free download pdf