to creat a polygon

Use a procedure that takes as input a positive integer and two real numbers a and b
and produces as output  a polygon centered at (a, b). Base on the procedure,  obtain a list of twenty decagons centered in (0, 0), (1, 1), ..(20, 20)

(I have no hint,please help, thanks)

alec's picture

geometry package

Such (or very similar) procedure already exists in geometry package. It is called RegularPolygon. It also includes radius that you didn't mention.

Assuming, for example, that the radius is 1, the procedure that you described, can be written as

poly:=proc(n::posint,a,b) 
local p,o;
uses geometry;
RegularPolygon(p,n,point(o,a,b),1);
draw(p) end;

The list of polygons can be drawn as

plots[display](seq(poly(10,i,i),i=0..20));

Alec

Hi, Alec. The way you do it

Hi, Alec. The way you do it is just list the decagons on the plot, but cannot list the points of the decagons. I actuaal solve this by differnet approach.But you give me a big help on starting a procedure. Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}