Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Synchronized Translations ( 3 0 points ) In this problem, we will write a function called shift.m which allows us to translate a three -

Synchronized Translations (30 points) In this problem, we will write a function
called shift.m which allows us to translate a three-dimensional object along the x, y, or
z axis by some specified amount. We will use this function to create a cool movie showing
moving objects.
On Canvas, there are files called setup.m and show2.m. These generate and plot an
object that well translate in various ways, using show2.m to visualize the results. It isnt
important to understand the details of the commands in these files, just how to use them.
For example, if you download these files then type
setup
show2(T,S)
youll see the object. Note that we will always call show2.m with the same variable T as
the first argument. The second argument will be a translation of S obtained through a
call to the function that youll write.
a)(10 pts) Write a function shift.m which takes as input a 3\times n matrix S (for example,
as obtained from running setup.m), a scalar dist which gives the distance that the object
should translate, and a string x,y, or z which tells which axis you want to translate
along.
This function should return a matrix of the same size as S, but with all elements in
the first row equal to their original values plus dist if the input string is x, all elements
in the second row equal to their original values plus dist if the input string is y, and
all elements in the third row equal to their original values plus dist if the input string is
z.
These actions correspond to translations of the object along the specified axis. For
example, the commands
setup
show2(T,shift(S,80,x))
should show the object translated by a distance of 80 along the x-axis.
b)(20 pts) Here you will write Matlab script called shift_movie.m which shows a movie
with three objects moving in the following ways. Except for the first one, each of these
steps should show multiple frames, which when shown in succession give a movie.
The three objects start on top of each other at their default position.
One object translates by increasing amounts in the +x direction, and one translates
by the same magnitudes in the x direction, until they are a distance of 80 away
from their original position.
The object which was translated in the x direction should now translate by in-
creasing amounts in the +z direction up to a height of 80. Simultaneously, the
object which was translated in the +x direction should translate by the same mag-
nitudes in the z direction down to z =80. These translations in the z direction
should occur with the objects maintaining their new x coordinate.
This previous step should be reversed, so that the objects return to their original
height while maintaining their new x coordinate.
The objects should return back to their original positions through appropriate trans-
lations along the x direction.
To make the movie, you can use successive application of code such as the following:
for counter = start:increment:stop
show2(T,S)
hold on
show2(T,shift(S,...);
show2(T,shift(S,...));
pause(0.05)
clf
end
the given code for show2.m is
function show2(T,S)
trisurf(T,S(1,:),S(2,:),S(3,:),'FaceColor','cyan','FaceAlpha', 0.8);
axis([-120120-120120-120120])
xlabel('x')
ylabel('y')
zlabel('z')
end
The given code for setup.m is
%tet1.m
clear;clc;
load tetmesh
TR = triangulation(tet,X);
[FBtri,FBpoints]= freeBoundary(TR);
T = FBtri;
S = FBpoints' -[zeros(1,1079);zeros(1,1079);40*ones(1,1079)];

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Grit and perseverance.

Answered: 1 week ago