Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 Spiral Triangle to Spiral Polygon [25 points) Recall that the following script generates spirals using equilateral triangles as shown in the figure below. Note

image text in transcribedimage text in transcribed

1 Spiral Triangle to Spiral Polygon [25 points) Recall that the following script generates spirals using equilateral triangles as shown in the figure below. Note the introduction of a new variable d_rot, which is accountable for the rotation of the innermost triangle. m = 21; d_angle = 4.5; d_rot = 90; th = linspace(0, 360, 4) + d_rot; V = [cosd(th); sind (th)]; C = colormap (hsv (m)); s = sind (150 - abs (d_angle)) /sind (30); R = (cosd (d_angle) -sind (d_angle); sind(d_angle) cosd (d_angle)]; hold off for i = 1:m if i > 1 V = S*R*V; end plot (v(1, :), V(2,:), Color', Cli, :)) hold on end set (gcf, 'Color', 'W') axis equal, axis off Figure 1: A spiral triangle with m = 21 and = 4.5. (a) Modify and generalize the script so that it generates spirals using m regular n-gons for any n> 3. Then turn the script into a function m-file spiralgon.m. function V = spiralgonin, m, d_angle, d_rot) & SPRIALGON plots spiraling regular n-gons % input: = the number of vertices m = the number of regular n-gons d_angle = the degree angle between successive n-gons (can be positive or negative) f d_rot = the degree angle by which the innermost n-gon is rotated % output: V = the vertices of the outermost n-gon % (b) Run the statements below to generate some aesthetic shapes. clf subplot (2, 2, 1), spiralgon (3, 41, 4.5, -90); subplot (2, 2, 2), spiralgon (4, 37, -2.5, 45); subplot (2, 2, 3), spiralgon (5, 61, 3, -90), subplot (2, 2, 4), spiralgon (8, 91, -4, 22.5)

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

10-5 Explain each of the main grounds for dismissal.

Answered: 1 week ago

Question

What is the difference between absolute and relative pay?

Answered: 1 week ago