Answered step by step
Verified Expert Solution
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 points In this problem, we will write a function
called shift.m which allows us to translate a threedimensional 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 showm These generate and plot an
object that well translate in various ways, using showm 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
showTS
youll see the object. Note that we will always call showm 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 pts Write a function shift.m which takes as input a 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 xy 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
showTshiftSx
should show the object translated by a distance of along the xaxis.
b pts Here you will write Matlab script called shiftmovie.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 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 Simultaneously, the
object which was translated in the x direction should translate by the same mag
nitudes in the z direction down to z 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
showTS
hold on
showTshiftS;
showTshiftS;
pause
clf
end
the given code for showm is
function showTS
trisurfTS:S:S:'FaceColor','cyan','FaceAlpha', ;
axis
xlabelx
ylabely
zlabelz
end
The given code for setup.m is
tetm
clear;clc;
load tetmesh
TR triangulationtetX;
FBtriFBpoints freeBoundaryTR;
T FBtri;
S FBpoints' zeros;zeros;ones;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started