Documentation Center

  • Trial Software
  • Product Updates

plot::Text3d

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::Text3d(text, [x, y, z], <a = amin .. amax>, options)

Description

plot::Text3d draws a text at a given position (x, y, z) (the "anchor point"). The attributes VerticalAlignment and HorizontalAlignment determine the alignment of the text w.r.t. its anchor.

Size, text color, font type etc. are controlled by the attribute TextFont.

In contrast to plot::Text2d, a 3D text cannot consist of several lines. The newline character \n in MuPAD® strings does not have an effect.

By default, a 3D text uses Billboarding = TRUE, i.e., the text is automatically oriented such that it is readable by the observer. When setting Billboarding = FALSE, the attribute TextOrientation allows to fix the orientation of the text arbitrarily in space. See the help page of TextOrientation for details.

The text of a text object can be animated if it is passed as a procedure that returns the text string during runtime. Cf. Example 5.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Billboardingtext orientation in space or towards observerTRUE
Framesthe number of frames in an animation50
HorizontalAlignmenthorizontal alignment of text objects w.r.t. their coordinatesLeft
Legendmakes a legend entry 
LegendTextshort explanatory text for legend 
LegendEntryadd this object to the legend?FALSE
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 
Textthe text of a text object 
TextFontfont of text objects[" sans-serif ", 11]
TextOrientationorientation of a 3D text[1, 0, 0, 0, 0, 1]
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0
Titleobject title 
TitleFontfont of object titles[" sans-serif ", 11]
TitlePositionposition of object titles 
TitleAlignmenthorizontal alignment of titles w.r.t. their coordinatesCenter
TitlePositionXposition of object titles, x component 
TitlePositionYposition of object titles, y component 
TitlePositionZposition of object titles, z component 
VerticalAlignmentvertical alignment of text objects w.r.t. their coordinatesBaseLine
VisiblevisibilityTRUE
VisibleAfterobject visible after this time value 
VisibleBeforeobject visible until this time value 
VisibleFromToobject visible during this time range 
VisibleAfterEndobject visible after its animation time ended?TRUE
VisibleBeforeBeginobject visible before its animation time starts?TRUE

Examples

Example 1

We draw the text string `Hello world' at the anchor point (1, 2, 3) which is indicated by a red dot:

plot(plot::Circle3d(3, [1, 2, 3], [0, 0, 1]),
     plot::Point3d([1, 2, 3]),
     plot::Text3d("Hello world!", [1, 2, 3],
                  HorizontalAlignment = Center),
     Axes = Frame, TextFont = [24],
     PointColor = RGB::Red, PointSize = 3*unit::mm)

Example 2

We animate the anchor points of the following texts and demonstrate various alignment possibilities:

plot(plot::Circle3d(1, [0, 0, 0], [0, 0, 1]),
     plot::Point3d([sin(a), cos(a), 0], a = 0..2*PI),
     plot::Point3d([cos(a), -sin(a), 0], a = 0..2*PI),
     plot::Point3d([-sin(a), -cos(a), 0], a = 0..2*PI),
     plot::Point3d([-cos(a), sin(a), 0], a = 0..2*PI),
     PointColor = RGB::Red, PointSize = 3*unit::mm,
     plot::Text3d("Hello (1)", [sin(a), cos(a), 0], a = 0..2*PI),
     plot::Text3d("Hello (2)", [cos(a), -sin(a), 0], a = 0..2*PI,
                  HorizontalAlignment = Left,
                  VerticalAlignment = BaseLine),
     plot::Text3d("Hello (3)", [-sin(a), -cos(a), 0], a = 0..2*PI,
                  HorizontalAlignment = Center,
                  VerticalAlignment = Top),
     plot::Text3d("Hello (4)", [-cos(a), sin(a), 0], a = 0..2*PI,
                  HorizontalAlignment = Right,
                  VerticalAlignment = Bottom),
     TextFont = [Italic, 24], Axes = Frame,
     CameraDirection = [0, -1, 10])

Example 3

In contrast to plot::Text2d, a 3D text may not consist of several lines. The newline character \n in MuPAD strings does not have any effect:

plot(plot::Text3d("A 3D text cannot \nhave several\nlines", 
                  HorizontalAlignment = Center,
                  [0, 0, 0]),
     Axes = Frame, TextFont = [20])

Example 4

Per default, the attribute Billboarding = TRUE is set. The text always faces the observer:

plot(plot::Circle3d(1, [0, 0, 0], [0, 0, 1]),
     plot::Point3d([-cos(a), -sin(a), 0], a = 0 .. 2*PI),
     plot::Point3d([cos(a), sin(a), 0], a = 0 .. 2*PI),
     plot::Text3d("Hello (1)", [-cos(a), -sin(a), 0],
                  a = 0 .. 2*PI),
     plot::Text3d("Hello (2)", [cos(a), sin(a), 0],
                  a = 0 .. 2*PI),
     Axes = Frame, TextFont = [20],
     PointColor = RGB::Red, PointSize = 2*unit::mm)

We use TextOrientation to fix the orientation of the texts in space. The first text lies in a plane parallel to the x-y plane, the second text is parallel to the x-z plane. Note that we have to specify Billboarding = FALSE for TextOrientation to have an effect:

plot(plot::Circle3d(1, [0, 0, 0], [0, 0, 1]),
     plot::Point3d([-cos(a), -sin(a), 0], a = 0 .. 2*PI),
     plot::Point3d([cos(a), sin(a), 0], a = 0 .. 2*PI),
     PointColor = RGB::Red, PointSize = 2*unit::mm,
     plot::Text3d("Hello (1)", [-cos(a), -sin(a), 0],
                  a = 0 .. 2*PI,
                  TextOrientation = [1, 0, 0, 0, 1, 0]),
     plot::Text3d("Hello (2)", [cos(a), sin(a), 0],
                  a = 0 .. 2*PI,
                  TextOrientation = [1, 0, 0, 0, 0, 1]),
     Billboarding = FALSE, TextFont = [20], Axes = Frame)

Example 5

The text of a text object can be animated if the text string is provided by a procedure. We use stringlib::formatf to format the animation parameter that is passed to the procedure as a floating-point number for each frame of the animation:

plot(plot::Text3d(a -> stringlib::formatf(a, 2, 5)." sec",
                  [0, 0, 0], a = 0..20),
     TextFont = [60], 
     HorizontalAlignment = Center, VerticalAlignment = Center,
     Axes = Frame, Frames = 201, TimeRange = 0..20)

Parameters

text

The text: a string. Alternatively, a procedure that accepts one input parameter a (the animation parameter) and returns a string.

text is equivalent to the attribute Text.

x, y, z

The position of the text. The coordinates x, y, z must be real numerical values or arithmetical expressions of the animation parameter a.

x, y, z are equivalent to the attributes Position, PositionX, PositionY, PositionZ.

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?