To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.
Back to EnglishTranslate This Page
MathWorks Machine Translation
The automated translation of this page is provided by a general purpose third party translator tool.
MathWorks does not warrant, and disclaims all liability for, the accuracy, suitability, or fitness for purpose of the translation.plot :: Surface
Parametrized surfaces in 3D
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.Description
plot::Surface creates a parametrized surface in 3D.
The surface given by a mapping (“parametrization”) is the set of all image points
The expressions/functions x , y , z may have singularities in the plot range. Although a heuristics is used to find a reasonable viewing range when singularities are present, it is highly recommended to specify a viewing box via the attribute ViewingBox = [xmin..xmax, ymin..ymax, zmin..zmax] with suitable numerical real values xmin,…,zmax . See Example 3.
Animations are triggered by specifying a range a = amin..amax for a parameter a that is different from the surface parameters u , v . See Example 5.
The functions x , y , z are evaluated on a regular equidistant mesh of sample points in the u - v plane. This mesh is determined by the attributes UMesh , VMesh . By default, the attribute AdaptiveMesh = 0 is set, i.e., no adaptive refinement of the equidistant mesh is used.
If the standard mesh does not suffice to produce a sufficiently detailed plot, one may either increase the value of UMesh , VMesh or USubmesh , VSubmesh , or set AdaptiveMesh = n with some (small) positive integer n . If necessary, up to 2 n - 1 additional points are placed in each direction of the u - v plane between adjacent points of the initial equidistant mesh. See Example 6.
The “coordinate lines” (“parameter lines”) are curves on the surface.
By default, the parameter curves are visible. They may be “switched off” by specifying ULinesVisible = FALSE and VLinesVisible = FALSE , respectively.
The coordinate lines controlled by ULinesVisible = TRUE/FALSE and VLinesVisible = TRUE/FALSE indicate the equidistant mesh in the u - v plane set via the UMesh , VMesh attributes. If the mesh is refined by the USubmesh , VSubmesh attributes, or by the adaptive mechanism controlled by AdaptiveMesh = n , no additional parameter lines are drawn.
As far as the numerical approximation of the surface is concerned, the settings UMesh = nu , VMesh = nv , USubmesh = mu , VSubmesh = mv and UMesh = (nu - 1) (mu + 1) + 1 , VMesh = (nv - 1) (mv + 1) + 1 , USubmesh = 0 , VSubmesh = 0 are equivalent. However, in the first setting, nu parameter lines are visible in the u direction, while in the latter setting (nu - 1) (mu + 1) + 1 parameter lines are visible. See Example 7.
Use Filled = FALSE to render the surface as a wireframe.Attributes Example 1
Using standard spherical coordinates, a parametrization of a sphere of radius r by the azimuth angle u ∈ [0, 2 π] and the polar angle v ∈ [0, π] is given by:
We fix r = 1 and create the surface object:
We call plot to plot the surface:
The parametrization can also be specified by piecewise objects or procedures:
We enable adaptive sampling to get a smoother graphical result:
We plot a surface with singularities:
We specify an explicit viewing range for the z coordinate:
By introducing non-real function evaluations, we can plot surfaces with holes:
We generate an animation of a surface of revolution. The graph of the function is rotated around the x -axis:
See plot::XRotate , plot::ZRotate for an alternative way to create surfaces of revolution.
The standard mesh for the numerical evaluation of a surface does not suffice to generate a satisfying plot in the following case:
We increase the number of mesh points. Here, we use USubmesh , VSubmesh to place 2 additional points in each direction between each pair of neighboring points of the default mesh. This increases the runtime for computing the plot by a factor of 9 :
Alternatively, we enable adaptive sampling by setting the value of AdaptiveMesh to some positive value:
By default, the parameter lines of a parametrized surface are “switched on”:
The parameter lines are “switched off”:
The number of parameter lines are determined by the attributes UMesh and VMesh :
When the mesh is refined via the attributes USubmesh , VSubmesh , the numerical approximation of the surface becomes smoother. However, the number of parameter lines is determined by the values of UMesh , VMesh and is not increased:
Klein's bottle is a surface without orientation. There is no “inside” and no “outside” of the following object:
Finally we create an animated surface plot of where a is the animation parameter:
The coordinate functions: arithmetical expressions or piecewise objects depending on the surface parameters u , v and the animation parameter a . Alternatively, procedures that accept 2 input parameters u , v or 3 input parameters u , v , a and return a numerical value when the input parameters are numerical.
The parametrization: a procedure that accepts 2 input parameters u , v or 3 input parameters u , v , a and returns a list of 3 numerical values [x, y, z] .
A matrix of category Cat::Matrix with three entries that provide the parametrization x , y , z
u is equivalent to the attribute UName .
The plot range for the parameter u : umin , umax must be numerical real values or expressions of the animation parameter a .
The second surface parameter: an identifier or an indexed identifier.
v is equivalent to the attribute VName .
The plot range for the parameter v : vmin , vmax must be numerical real values or expressions of the animation parameter a .
Animation parameter, specified as a = amin..amax , where amin is the initial parameter value, and amax is the final parameter value.MuPAD Functions MuPAD Graphical Primitives Select Your Country
Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a location from the following list:
Using Analytical Tools to Gain Insight and Speed Up Numerical Analysis in MATLAB Explore Products Try or Buy Learn to Use Get Support About MathWorks
Accelerating the pace of engineering and science
MathWorks is the leading developer of mathematical computing software for engineers and scientists.
When we view a picture containing non-transparent objects and surfaces, then we cannot see those objects from view which are behind from objects closer to eye. We must remove these hidden surfaces to get a realistic screen image. The identification and removal of these surfaces is called Hidden-surface problem.
There are two approaches for removing hidden surface problems − Object-Space method and Image-space method. The Object-space method is implemented in physical coordinate system and image-space method is implemented in screen coordinate system.
When we want to display a 3D object on a 2D screen, we need to identify those parts of a screen that are visible from a chosen viewing position.Depth Buffer (Z-Buffer) Method
This method is developed by Cutmull. It is an image-space approach. The basic idea is to test the Z-depth of each surface to determine the closest (visible) surface.
In this method each surface is processed separately one pixel position at a time across the surface. The depth values for a pixel are compared and the closest (smallest z) surface determines the color to be displayed in the frame buffer.
It is applied very efficiently on surfaces of polygon. Surfaces can be processed in any order. To override the closer polygons from the far ones, two buffers named frame buffer and depth buffer, are used.
Depth buffer is used to store depth values for (x, y) position, as surfaces are processed (0 ≤ depth ≤ 1).
The frame buffer is used to store the intensity value of color value at each position (x, y).
The z-coordinates are usually normalized to the range [0, 1]. The 0 value for z-coordinate indicates back clipping pane and 1 value for z-coordinates indicates front clipping pane.
Depthbuffer (x, y) = 0
Framebuffer (x, y) = background color
Step-2 − Process each polygon (One at a time)
For each projected (x, y) pixel position of a polygon, calculate depth z.
If Z > depthbuffer (x, y)
Compute surface color,
set depthbuffer (x, y) = z,
framebuffer (x, y) = surfacecolor (x, y)Advantages
It is an image-space method to identify visible surface. This method has a depth information for only single scan-line. In order to require one scan-line of depth values, we must group and process all polygons intersecting a given scan-line at the same time before processing the next scan-line. Two important tables, edge table and polygon table, are maintained for this.
The Edge Table − It contains coordinate endpoints of each line in the scene, the inverse slope of each line, and pointers into the polygon table to connect edges to surfaces.
The Polygon Table − It contains the plane coefficients, surface material properties, other surface data, and may be pointers to the edge table.
To facilitate the search for surfaces crossing a given scan-line, an active list of edges is formed. The active list stores only those edges that cross the scan-line in order of increasing x. Also a flag is set for each surface to indicate whether a position along a scan-line is either inside or outside the surface.
Pixel positions across each scan-line are processed from left to right. At the left intersection with a surface, the surface flag is turned on and at the right, the flag is turned off. You only need to perform depth calculations when multiple surfaces have their flags turned on at a certain scan-line position.Area-Subdivision Method
The area-subdivision method takes advantage by locating those view areas that represent part of a single surface. Divide the total viewing area into smaller and smaller rectangles until each small area is the projection of part of a single visible surface or no surface at all.
Continue this process until the subdivisions are easily analyzed as belonging to a single surface or until they are reduced to the size of a single pixel. An easy way to do this is to successively divide the area into four equal parts at each step. There are four possible relationships that a surface can have with a specified area boundary.
Surrounding surface − One that completely encloses the area.
Overlapping surface − One that is partly inside and partly outside the area.
Inside surface − One that is completely inside the area.
Outside surface − One that is completely outside the area.
The tests for determining surface visibility within an area can be stated in terms of these four classifications. No further subdivisions of a specified area are needed if one of the following conditions is true −
A fast and simple object-space method for identifying the back faces of a polyhedron is based on the "inside-outside" tests. A point (x, y, z) is "inside" a polygon surface with plane parameters A, B, C, and D if When an inside point is along the line of sight to the surface, the polygon must be a back face (we are inside that face and cannot see the front of it from our viewing position).
We can simplify this test by considering the normal vector N to a polygon surface, which has Cartesian components (A, B, C).
In general, if V is a vector in the viewing direction from the eye (or "camera") position, then this polygon is a back face if
Furthermore, if object descriptions are converted to projection coordinates and your viewing direction is parallel to the viewing z-axis, then −
So that we only need to consider the sign of C the component of the normal vector N.
In a right-handed viewing system with viewing direction along the negative $Z_
Similar methods can be used in packages that employ a left-handed viewing system. In these packages, plane parameters A, B, C and D can be calculated from polygon vertex coordinates specified in a clockwise direction (unlike the counterclockwise direction used in a right-handed system).
Also, back faces have normal vectors that point away from the viewing position and are identified by C >= 0 when the viewing direction is along the positive $Z_
The A-buffer method is an extension of the depth-buffer method. The A-buffer method is a visibility detection method developed at Lucas film Studios for the rendering system Renders Everything You Ever Saw (REYES).
The A-buffer expands on the depth buffer method to allow transparencies. The key data structure in the A-buffer is the accumulation buffer.
Each position in the A-buffer has two fields −
Depth field − It stores a positive or negative real number
Intensity field − It stores surface-intensity information or a pointer value
If depth >= 0, the number stored at that position is the depth of a single surface overlapping the corresponding pixel area. The intensity field then stores the RGB components of the surface color at that point and the percent of pixel coverage.
If depth < 0, it indicates multiple-surface contributions to the pixel intensity. The intensity field then stores a pointer to a linked list of surface data. The surface buffer in the A-buffer includes −
The algorithm proceeds just like the depth buffer algorithm. The depth and opacity values are used to determine the final color of a pixel.Depth Sorting Method
Depth sorting method uses both image space and object-space operations. The depth-sorting method performs two basic functions −
First, the surfaces are sorted in order of decreasing depth.
Second, the surfaces are scan-converted in order, starting with the surface of greatest depth.
The scan conversion of the polygon surfaces is performed in image space. This method for solving the hidden-surface problem is often referred to as the painter's algorithm. The following figure shows the effect of depth sorting −
The algorithm begins by sorting by depth. For example, the initial “depth” estimate of a polygon may be taken to be the closest z value of any vertex of the polygon.
Let us take the polygon P at the end of the list. Consider all polygons Q whose z-extents overlap P’s. Before drawing P, we make the following tests. If any of the following tests is positive, then we can assume P can be drawn before Q.
If all the tests fail, then we split either P or Q using the plane of the other. The new cut polygons are inserting into the depth order and the process continues. Theoretically, this partitioning could generate O(n 2 ) individual polygons, but in practice, the number of polygons is much smaller.Binary Space Partition (BSP) Trees
Binary space partitioning is used to calculate visibility. To build the BSP trees, one should start with polygons and label all the edges. Dealing with only one edge at a time, extend each edge so that it splits the plane in two. Place the first edge in the tree as root. Add subsequent edges based on whether they are inside or outside. Edges that span the extension of an edge that is already in the tree are split into two and both are added to the tree.
From the above figure, first take A as a root.
Make a list of all nodes in figure (a).
Put all the nodes that are in front of root A to the left side of node A and put all those nodes that are behind the root A to the right side as shown in figure (b).
Process all the front nodes first and then the nodes at the back.
As shown in figure (c), we will first process the node B. As there is nothing in front of the node B, we have put NIL. However, we have node C at back of node B, so node C will go to the right side of node B.
Repeat the same process for the node D.
© Copyright 2017. All Rights Reserved.
The following will let the user move objects along their Z axis to fit a specified surface. Such a script can be used to automatically plant trees, poles etc. on the ground.
This script is straight out of the 3ds Max MAXScript reference file. Its part of the MAXScript 'How To' lessons that teaches how to use MAXScript with practical problems. Load your MAXScript reference (the one that ships with 3ds Max) and do a search for 'align surface' and it'll be the first result.
I did not write this script I merely copied the code here as aligning to a surface is a very common request. Make sure to read the other 'How To' tutorials in the 3ds Max MAXScript reference - they're all really good!
To install go to MAXScript / Run Script and select this file. Now go to Customize / Customize User Interface and you'll find the script in the 'How To' category on the left. Add it to a menu bar, assign a shortcut, whatever you want.
To use, select all your objects you want to align, run the script then select the object to align to and voila they align!
thank you - very usefull script - i think it is much faster with lots of objects than scripted-glu
© Sports Predictions 2018