plot::Transform3d

Affine linear transformation of 3D objects

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

plot::Transform3d(<b3d>, A3d, obj1, <obj2, …>, <a = amin .. amax>, options)

Description

plot::Transform3d(b, A, objects) transforms 3D objects accordingly.

The transformation matrix A may be specified by a list of lists

[[A1, 1, A1, 2, …], [A2, 1, A2, 2, …], …]

with the sublists representing the rows.

A plain list

[A1, 1, A1, 2, …, A3, 2, A3, 3]

represents the matrix row by row in 3D.

Transform objects can transform several graphical objects simultaneously. Plotting the transform object renders all graphical objects inside.

Transformed objects have a tendency to overestimate their ViewingBox. Cf. the help page of ViewingBox. In such a case, you should specify a suitable ViewingBox explicitly.

Transformation objects can be used inside transformation objects. If they are animated, the animations run simultaneously.

Animated transform objects are rather "cheap" concerning computing and storing costs. For more complex graphical objects, it is more efficient to use an animated transform object than to redefine the object for each frame.

The function op allows to extract the graphical objects inside a transformation object.

Attributes

AttributePurposeDefault Value
AffectViewingBoxinfluence of objects on the ViewingBox of a sceneTRUE
Framesthe number of frames in an animation50
Matrix3dtransformation matrices[1, 0, 0, 0, 1, 0, 0, 0, 1]
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 
Shiftshift vector[0, 0, 0]
ShiftXshift vector0
ShiftYshift vector0
ShiftZshift vector0
TimeEndend time of the animation10.0
TimeBeginstart time of the animation0.0
TimeRangethe real time span of an animation0.0 .. 10.0

Examples

Example 1

We visualize a linear transformation without shift:

x1 := plot::Arrow2d([0, 0], [1/3, 1], Color = RGB::Red):
x2 := plot::Arrow2d([0, 0], [1, 1], Color = RGB::Green):
x3 := plot::Arrow2d([0, 0], [1, 1/3], Color = RGB::Blue):
A :=  matrix([[1, -2], [-2, 1]]):
plot(plot::Scene2d(x1, x2, x3),
     plot::Scene2d(plot::Transform2d(A, x1, x2, x3)),
     Scaling = Constrained, Layout = Horizontal):

delete x1, x2, x3, A:

Example 2

For some applications, it is very popular to plot a function in 3D together with a projection of its contour lines onto the lower or upper bounding plane. MuPAD® has no direct option for this, but with plot::Transform3d, it is possible to achieve the same effect. Assume you have the function under consideration in a plot::Function3d object:

f := plot::Function3d(sin(x*y)+cos(x^2-y),
                      x=-3..3, y=-3..3, Submesh=[1,1]):

To plot contour lines at all, we use the attribute ZContours. Since we don't want to change our f, we create a modified copy using plot::modify:

plot(plot::modify(f, ZContours = [Automatic, 10]))

To only get contour lines, we have to change a few more parameters: We need to switch off the surface and the parameter lines. Then, we add height coloring to our lines and use plot::Transform3d to project them onto the plane z = - 2.5. Finally, we plot these lines together with the original function:

plot(f,
     plot::Transform3d([0, 0, -2.5], // shift vector
                       [1, 0, 0,  // transformation matrix
                        0, 1, 0,
                        0, 0, 0],
             plot::modify(f,
                    Filled = FALSE,
                    XLinesVisible = FALSE, YLinesVisible = FALSE,
                    ZContours = [Automatic, 10],
                    LineColorFunction =  // height coloring
                ((x, y, z) -> [(z+2)/4, 0, (2-z)/4]))))

Parameters

b3d

The 3D shift vector: a list with 3 entries. Also vectors generated by matrix or arrays are accepted. The entries must be numerical values or arithmetical expressions of the animation paramater a.

b3d is equivalent to the attribute Shift.

A3d

The 3D transformation matrix: a 3×3 matrix, a 3×3 array, a list of 3 lists, or a plain list with 9 entries. The entries must be numerical values or arithmetical expressions of the animation paramater a.

A3d is equivalent to the attribute Matrix3d.

obj1, obj2, …

Plot objects of the appropriate dimension

a

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

Was this topic helpful?