| Contents | Index |
plot::Text3d(text, [x, y, z]) draws the text string text at the position
.
Call:
plot::Text3d(text, [x, y, z], <a = amin .. amax>, Options)
Parameters:
|
text: |
the text: a string. Alternatively, a procedure that accepts one input parameter |
|
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. |
See Also:
plot, plot::copy, plot::Text2d, stringlib::formatf
Details:
plot::Text3d draws a text at a given position
(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.
Example 1
We draw the text string `Hello world' at the anchor point
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
-
plane, the second text is parallel to the
-
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)



Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |