Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following program in Octave console or Scilab (Translation of the S

ID: 3866331 • Letter: C

Question

Complete the following program in Octave console or Scilab (Translation of the Scaled Rectangle)

Build the Starting Rectangle

1

2

3

4

5

6

7

8

9

10

11

XR=2;

XL=-XR;

YT= 1;

YB=-YT;

corners = zeros(5,3);

corners(1,:) = [XR YT 1];

corners(2,:) = [XL YT 1];

corners(3,:) = [XL YB 1];

corners(4,:) = [XR YB 1];

corners(5,:) = corners(1,:);

plot2(corners(:,[1 2]),"title", "Initial Box", "chartType" , "line","xyminmax",[-10,10,-10,10]);

Rotate the Rectangle

This part starts with the corners from the last step and rotates it Pi/4 radians (remember that all of the trig functions use radians). The steps are shown here:

1

2

3

4

5

rotMat = [cos(pi/4) -sin(pi/4) 0;sin(pi/4) cos(pi/4) 0;0 0 1];

rcorners=(rotMat*corners')';

pData = corners(:,[1 2]);

pData = buildPlotData2(pData,rcorners(:,1),rcorners(:,2));

plot2(pData,"title", "Initial Box + Rotation", "chartType" , "line","legendnames",{"X","Initial","Rotated"},"xyminmax",[-10,10,-10,10]);

Scale the Rectangle

Once again, the scaling matrix is referenced on page 142. Generically this is given by

Then the scaling of the area of the new matrix is given by det(Scale). In the example below, the area scales by a factor of 2.

1

2

3

4

5

sF = 2;

scalMat = [sqrt(sF) 0 0; 0 sqrt(sF) 0; 0 0 1];

rscorners=(scalMat*rcorners')';

pData = buildPlotData2(pData,rscorners(:,1),rscorners(:,2));

plot2(pData, "title", "Initial Box+Rotation+Scale", "chartType" , "line","legendnames",{"X","Initial","Rotated","Rotated + Scaled"},"xyminmax",[-10,10,-10,10]);

----------------------------------------------------------------------------------------------------------------------------------------------------

Translation of the Scaled Rectangle

From page 142, the translation matrix is given by

where all of the points are translated by (X,Y). This time you will create the commands!

1.Create a translation matrix to translate by (2,3)

2.Multiply the translation matrix times rscorners.

3.Don't forget to use the NaN array since you are creating an image with four separate objects.

1

2

3

4

5

6

7

8

9

10

11

XR=2;

XL=-XR;

YT= 1;

YB=-YT;

corners = zeros(5,3);

corners(1,:) = [XR YT 1];

corners(2,:) = [XL YT 1];

corners(3,:) = [XL YB 1];

corners(4,:) = [XR YB 1];

corners(5,:) = corners(1,:);

plot2(corners(:,[1 2]),"title", "Initial Box", "chartType" , "line","xyminmax",[-10,10,-10,10]);

Scale=10 0 0 0 1

Explanation / Answer

We see sine curves in many naturally occuring phenomena, like water waves. When waves have more energy, they go up and down more vigorously. We say they have greater amplitude.

Let's investigate the shape of the curve y = a sin t and see what the concept of "amplitude" means.

Have a play with the following interactive.

Sine curve Interactive

You can change the circle radius (which changes the amplitude of the sine curve) using the slider.

The scale along the horizontal t-axis (and around the circle) is radians. Remember that radians is displaystyle{180}^{circ}180, so in the graph, the value of displaystylepi={3.14}=3.14 on the t-axis represents displaystyle{180}^{circ}180 and displaystyle{2}pi={6.28}2=6.28 is equivalent to displaystyle{360}^{circ}360.

The "a" in the expression y = a sin x represents the amplitude of the graph. It is an indication of how much energy the wave contains.

The amplitude is the distance from the "resting" position (otherwise known as the mean value or average value) of the curve. In the interactive above, the amplitude can be varied from displaystyle{10}10 to displaystyle{100}100 units.

Amplitude is always a positive quantity. We could write this using absolute value signs. For the curve y = a sin x,

amplitude displaystyle={left|{a} ight|}=a

The sine and cosine graphs are almost identical, except the cosine curve starts at displaystyle{y}={1}y=1 when displaystyle{t}={0}t=0 (whereas the sine curve starts at displaystyle{y}={0}y=0). We say the cosine curve is a sine curve which is shifted to the left by displaystyle rac{pi}{{2}} {left(={1.57}={90}^{circ} ight)}2 (=1.57=90).

The value of the cosine function is positive in the first and fourth quadrants (remember, for this diagram we are measuring the angle from the vertical axis), and it's negative in the 2nd and 3rd quadrants.

Now let's have a look at the graph of the simplest cosine curve, y = cos x (= 1 cos x).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote