Question: Please using matlab stuck on problem 3 Problem 2 Use a function (polar rose or spiral or anything else reasonable) to create (x,y) points. Move

Please using matlab

stuck on problem 3

Problem 2

Use a function (polar rose or spiral or anything else reasonable) to create (x,y) points. Move it to a new location using a rotation followed by a translation. Plot it again. Extra credit: Plot multiple copies in a circle or a grid or some other pattern using a for loop.

Deliverables:

Script to create the function and do the plot

Function to create x,y values

Put x,y values into a 3xn matrix

Use a matrix to move the points

Picture with your original and moved points

EC: Plot with multiple copies. Must use a loop (dont do it by hand)

Step by Step Instructions:

Create x and y points using either a spiral or a polar rose

Polar rose: r(t) is cos( n/d *t ) I used n = 4, d = 3 in the plot below

Spiral: r(t) is sqrt(t) (see lecture script)

x(t) = r(t) * cos(t)

y(t) = r(t) * sin(t)

Plot and make sure you have either a spiral or a rose. Use axis equal to make sure the aspect ratio is correct

Note: You can do anything you want here just produce x and y points that make an interesting plot one that you can tell if you rotated it correctly or not

Turn your x and y vectors into a 3xn matrix where n is the length of x and y

pts = [x; y; ones( 1, length(x) ) ]

Copy your mTrans and mRot code from the previous problem

Multiply the matrics by the points

ptsNew = mTrans * mRot * pts

Plot the new points. Notice that ptsNew is also a 3xn matrix with ones in the 3rd row ignore those

Problem 3

Plot your shape from problem 2 in 3D. Use a function to create x,y, and z points.

Create a wavy surface and plot it using surf

Deliverables:

Script to do the plots

Function to create the 3D data points for the first plot (can be any function youd like)

Function to create the height data for the second plot (can be any function youd like)

Screen shot of the plots from two different view points

Step by Step Instructions:

The 3D plot: Create a function file that takes in t and returns x,y and zCopy in your code from the previous problem to make x and y from t

If you, eg, want to pass in n and d or some other parameters, feel free

Set z to be some function of t I used cos(t) in the picture below

In the calling script create t and pass it to your function to create the x,y,z values

[x, y, z] = My3DFc( t )

Use plot3 to plot this in 3D

The surfaceCreate a function file mySrfF that takes in s and t and returns z

This can be any function youd like you can use the one from lecture or the plywood function from the homework or just make something up

Make sure to use element-wise multiplication

In the calling script make a grid of values using meshgrid

s = linspace(-pi, pi);

t = linspace(-pi, pi);

[S, T] = meshgrid(s,t)

- note, I used a bigger range for the plot below

Use these values to get your z values

Z = mySrfFc(S,T)

Plot using surf

surf( S, T, Z);

Plot that way then try

surf( S, T, Z, FaceColor, [ 0.5 0.5 0.5], EdgeColor, None);

camlight left;

lighting phong;

To rotate the camera use the rotate tool

You can also set the camera viewpoint from within the code

view( 45, 60 )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!