plot::SpotLight

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::SpotLight([px, py, pz], [tx, ty, tz], angle, <intensity>, <a = amin .. amax>, options)

Description

plot::SpotLight([px, py, pz], [tx, ty, tz], angle, intensity) generates a spot light at the position px, py, pz, aimed at the point tx, ty, tz. The opening angle of the light cone is given by angle.

Each 3D scene is illuminated by several light sources that are set automatically and cannot be controlled by the user. Cf. the help page of Lighting.

If special light effects are desired, the user can create alternative light sources of various types such as plot::AmbientLight, plot::DistantLight, plot::PointLight, and plot::SpotLight.

If at least one user defined light source is inserted into the scene (e.g., by simply passing the light objects as input parameters to the plot command), the automatic lights are switched off and the user defined lights are used to illuminate the scene.

plot::SpotLight([px, py, pz], [tx, ty, tz], angle) creates a spot light source at the point [px, py, pz] emitting a light cone towards the point [tx, ty, tz]. In contrast to real life, the light flux of a spot light does not decrease with the distance to the light source.

By default, white light is created. Other colours can be chosen by the attribute LightColor.

When using the attribute CameraCoordinates = TRUE, the light source is fixed to the camera. It moves automatically, when the camera is moved.

Directed light such as plot::SpotLight create shading effects that add depth to the picture.

Usually, you will use spot lights to highlight special details of the scene. For the illumination of the entire scene you will usually need additional undirected ambient light of type plot::AmbientLight, too.

Note that all light sources create a homogeneous lighing effect for a 3D triangle. Thus, realistic shading effects can only be achieved for surfaces with a sufficiently fine triangulation. For function graphs (plot::Function3d) and parametrized surfaces (plot::Surface), a fine triangulation is created by sufficiently high values of XMesh, YMesh or UMesh, VMesh, respectively.

Attributes

AttributePurposeDefault Value
CameraCoordinatesposition of light sources relative to the camera?FALSE
Framesthe number of frames in an animation50
LightColorthe color of lightRGB::White
LightIntensityintensity of light1.0
Namethe name of a plot object (for browser and legend) 
ParameterEndend value of the animation parameter 
ParameterNamename of the animation parameter 
ParameterBegininitial value of the animation parameter 
ParameterRangerange of the animation parameter 
Positionpositions of cameras, lights, and text objects 
PositionXx-positions of cameras, lights, and text objects 
PositionYy-positions of cameras, lights, and text objects 
PositionZz-positions of cameras, lights, and text objects 
SpotAngleopening angle of the light cone of a spot light 
Targetthe target point of a light 
TargetXthe target point of a light, x component 
TargetYthe target point of a light, y component 
TargetZthe target point of a light, z component 
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
VisiblevisibilityTRUE

Examples

Example 1

We create three white surfaces and illuminate them by two animated white spot lights and some ambient light. The spot lights are indicated by little cones:

s1 := plot::Surface([1, y, z], y = 0..1, z = 0..1):
s2 := plot::Surface([x, 1, z], x = 0..1, z = 0..1,
                    Submesh = [2, 2]):
s3 := plot::Surface([x, y, 0], x = 0..1, y = 0..1,
                    Submesh = [2, 2]):
ambientlight:= plot::AmbientLight(0.4):
spotlight1 := plot::SpotLight([1/3, a, 1/3], [1/3, 1, 1/3], 
                              PI/5, a = 0..0.8):
c1 := plot::Cone(0, [1/3, a, 1/3],
                 0.2*tan(PI/10), [1/3, a + 0.2, 1/3],
                 a = 0..0.8, Color = RGB::Orange.[0.5]):
spotlight2 := plot::SpotLight([2/3, a, 2/3], [2/3, a, 0], 
                              PI/4, a = 0.15..0.95):
c2 := plot::Cone(0, [2/3, a, 2/3], 
                 0.2*tan(PI/8), [2/3, a, 2/3 - 0.2],
                 a = 0.15..0.95, Color = RGB::Orange.[0.5]):
plot(s1, s2, s3, FillColor = RGB::White, 
     FillColorType = Flat,
     ambientlight, c1, spotlight1, 
     c2, spotlight2, Axes = Frame):

delete s1, s2, s3, c1, c2, ambientlight, 
       spotlight1, spotlight2:

Parameters

px, py, pz

The coordinates of the position: numerical values or arithmetical expressions of the animation parameter a.

px, py, pz are equivalent to the attributes Position, PositionX, PositionY, PositionZ.

tx, ty, tz

The coordinates of the point the light is shining to: numerical values or arithmetical expressions of the animation parameter a.

tx, ty, tz are equivalent to the attributes Target, TargetX, TargetY, TargetZ.

angle

The opening angle of the light cone in radians: a numerical value between 0 and π or an arithmetical expression of the animation parameter a.

angle is equivalent to the attribute SpotAngle.

intensity

The intensity of the light: a numerical value between 0 and 1 or an arithmetical expression of the animation parameter a.

intensity is equivalent to the attribute LightIntensity.

a

Animation parameter, specified as a = amin..amax, where amin is the initial parameter value, and amax is the final parameter value.

See Also

MuPAD Functions

MuPAD Graphical Primitives

Was this topic helpful?