how i can do this geometry program

In order to have a closed geometric figure composed of straight lines , angles in figure must sum
( - 2) ( 180 ) degrees
Where n is the number of sides .
a) Try this statement yourself by creating a vector called n from 3 to 6 and calculate the sum of angle from the formula. Compare what you know about geometry with his answer.
b ) Write a program that enjoin the user to enter one of the following : Triangulo
Square Pentagon Hexagon
Use the entry to set the value of n using a switch / case structure ; then use n to calculate the sum of the interior angles of the figure.
c ) Rephrase your program from part b so use a menu.

回答(1 个)

My shape recognition demo may help you. There is a function in it to create regular polygons. This is the code to look for:
%----------------------------------------------------------------------------------------------------------------------------------
% Create a single polygon with the specified number of sides in a binary image of the specified number of rows and columns.
% centroidToVertexDistance is the distance from the centroid to each vertex.
% If centroidToVertexDistance is a length 2 vector, then this indicated the minimum and maximum size range and
% it will create a random size polygon between the min and max distance.
function binaryImage = CreatePolygon(numSides, centroidToVertexDistance, rows, columns)
Feel free to adapt it to your needs.

类别

帮助中心File Exchange 中查找有关 Mathematics 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by