Positions of cameras, lights, and text objects
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
Position determines the positions of cameras,
lights, and text objects.
PositionX etc. refer to the single coordinate
values of the position.
Position refers to the location
of a camera taking pictures of
a 3D scene. Its a value is a list or vector of coordinates.
Also the position of light sources illuminating the 3D scene
is set by
Position determines the coordinates
where text objects are to be placed.
These attributes can be animated. Animating a camera position one can realize a flight through a 3D scene.
By default, the position of lights is given in model coordinates that have nothing to do with the camera that is used to view the scene.
CameraCoordinates also allows to position
a light relative to the camera. In particular, the light moves automatically,
when the camera is moved.
We define a 3D scene consisting of a function, a distant light, and a camera. The light shines from the direction of the camera:
f := plot::Function3d(sin(x^2 - y^2), x = -2..2, y = -2..2, Color = RGB::White): light := plot::DistantLight([3, 4, 5], [0, 0, 0], 0.75, Color = RGB::Yellow): camera := plot::Camera([3, 4, 5], [0, 0, 0], 0.25*PI): plot(f, light, camera)
We animate the camera position but keep the light position fixed:
camera::Position := [3*sqrt(2)*cos(a + PI/4), 4*sqrt(2)*sin(a + PI/4), 5*(0.7 + 0.3*cos(2*a))]: camera::ParameterName := a: camera::ParameterRange := 0..2*PI: plot(f, light, camera)
Using the same objects, we fix the camera and animate the light position:
camera::Position := [3, 4, 5]: camera::Frames := 1: light::Position := [3*sqrt(2)*cos(a + PI/4), 4*sqrt(2)*sin(a + PI/4), 5]: light::ParameterName := a: light::ParameterRange := 0..2*PI: plot(f, light, camera)
delete f, light, camera: