Using your file handling skills from the previous recitation, read the x y z coo
ID: 3684979 • Letter: U
Question
Using your file handling skills from the previous recitation, read the x y z coordinates for each point in the input file into three vectors named x, y, and z. Skip the header lines (lines with text) at the beginning of the file. Plot the points using the plot3 function. Find the rotate tool in the figure menu and look at the object from different perspectives to identify it. To show this object on the screen, the plot3 function has to project the object, that is it has to transform the 3 dimensional into a 2 dimensional image that can be shown on our 2 dimensional screen. A basic form of projection can be obtained by simply omitting one of coordinates (either x, y, or z) from each point. Use the plot function (not plot3) to plot the x and y coordinates of the points. Use the plot function to also create plots from 2 additional (different) perspectives. Your plot should look as shown below. To plot the object, the computer has to transform the set of points into a raster image, when the plot function is called. To understand this process, write a script that can show the set of points on the screen without using any of the plotting functions. Instead, create an image matrix that can be displayed with the function in show. Proceed in the following steps: (i) create an image matrix that represents an all black image, say 400 pixels wide and 400 pixels high (ii) for each of the points (x, y, z) read from the file, omit one of the coordinate to project the point into 2 dimensions, translate (add to) all coordinates by the same amount so that they all fall into the range [0, 400]. You may want to check the minimum and maximum value of all coordinates to confirm. Convert the coordinates to integers using the unitl6 function, (iii) Set the matrix value/pixel described by the remaining two coordinates to the purest and brightest shade of green. (iv) display the image using irnshowExplanation / Answer
The plot3 function displays a three-dimensional plot of a set of data points.
plot3(X1,Y1,Z1,...), where X1, Y1, Z1 are vectors or matrices, plots one or more lines in three-dimensional space through the points whose coordinates are the elements of X1, Y1, and Z1.
plot3(X1,Y1,Z1,LineSpec,...) creates and displays all lines defined by the Xn,Yn,Zn,LineSpec quads, where LineSpec is a line specification that determines line style, marker symbol, and color of the plotted lines
plot3(...,'PropertyName',PropertyValue,...) sets line properties to the specified property values for all the charting lines created by plot3. See Chart Line Properties for a description of the properties you can set.
plot3(ax,...) creates the line in the axes specified by ax instead of in the current axes (gca). The option ax can precede any of the input argument combinations in the previous syntaxes.
h = plot3(...) returns a column vector of chart line objects.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.