polygonbyname - Maple Help

plottools

 polygonbyname
 create plot structures for regular polygons

 Calling Sequence polygonbyname( shape ) polygonbyname( shape, inbox=[width, height], opts ) polygonbyname( shape, radius=r, opts)

Parameters

 shape - string describing a regular polygon or a number of sides width, height - real numbers specifying the width and height of an inscribed rectangle r - real number specifying the radius of an inscribed circle opts - (optional) sequence of equations of the form option=value

Options

 • Any applicable 2-D plot option in plot/options can also be given.
 • bbox = list
 Specify the length and width of a centered bounding box into which the shape should fit completely. If it does not fit, it is scaled to fit exactly. Checking for fit and scaling is done before any rotation is applied.
 • center = list
 Specify the coordinates of the center of the polygon. The default is [0,0].
 • inbox = listlist
 Specify a rectangle with the same center as center that must fit inside the polygon.
 • irregular = truefalse or a positive value
 Randomly perturb the vertices of the shape to make it irregular. irregular=true is equivalent to irregular=0.1. A numeric value for irregular specifies the factor of the length of the side by which points may be perturbed. The default is false.
 Specify a circle with radius r with the same center as the polygon that must fit inside the polygon.
 • rotation = realcons with or without units
 Specify a counterclockwise rotation angle. If no units are included, radians are assumed.
 • rounded = truefalse or a number between 0 and 1
 Rounds the corners of a convex shape with corners having radius the given fraction of the size of the shape, defaults to 1/5 when rounded=true. The default is false.
 • star = truefalse or a real number
 Draw a star version of the polygon, optionally specifying how long the points should be. The default is false.
 • wide = truefalse
 If true and the size of the polygon is given by an inscribed rectangle, scale the polygon vertically as little as possible so that the sides of its bounding box have the same ratio as the sides of inbox.

Description

 • This command draws a polygon given by number of sides or the name of a shape.
 • The size of the polygon can be given by either the dimensions of a rectangle with the same center that must fit inside the polygon or by the radius of an inscribed circle. If both inbox and radius are given then the one specifying the larger polygon is used. If neither are given, a unit golden rectangle is used for inbox.
 • The following shapes are drawn smaller than an inscribed circle to better fit the inscribed rectangle: "rectangle", "ellipse", and other regular axis-aligned four-sided shapes.
 • All other shapes are drawn to fit around the circumscribed circle of the inbox rectangle.  The wide and irregular options may result in shapes that do not quite enclose the inbox rectangle, but the fit will usually be close.
 • If a shape must be made to fit exactly in a space, the bbox option can be used to give the dimensions of a bounding box for the shape.

Shape Names

 • A polygon can be specified as "ngon" where n is a positive integer
 • Special shapes include circle, semicircle, ellipse, rectangle, stadium, halfstadium, indentstadium, superellipse, and supercircle. The star, rounded, irregular, and wide options do not work with these shapes.
 • The special shape hat, its reflection rhat, and spectre  are recognized. These are shapes that can tile the plane only aperiodically.
 • More general superellipses can be specified as n-superellipse and [m,n]-superellipse.  See plottools:-ellipse for details.
 • The following special quadrilaterals are also understood: rectangle, square, parallelogram, trapezoid, trapezium, diamond, kite, invkite, dart, and rhombus. The star, and irregular options do not work with these shapes.
 • For convenience, the base string star is converted to 5gram and n star converted to n gram.
 • Most Greek-style names for regular polygon are supported. Shapes are all drawn with a bottom edge parallel with the x-axis.
 • Shape names can be prefixed with star, inverted (or inv for short), rounded and wide to modify the shape without using the option. The inverted modifier is a rotation, depending on the number of sides of the polygon, which orients the polygon so that a corner is at the top.
 • The rounded modifier does not work with non-convex shapes or already rounded shapes and is ignored for polygons with more than 20 sides. If a rounded polygon is specified with the rounded=number then the number is taken as a multiplier of the size of the polygon to use as the radius of the rounded corners.  The default multiplier is 0.2.
 • Regular polygons with rounded sides called Reuleaux polygons are also supported. Reuleaux polygons cannot be modified with rounded, star, or irregular options.
 • Regular star polygons are drawn with points at the length that makes the edges on either side of any point lie on the same line. If a star polygon is specified with the star=number option, the number is used as a multiplier of the length of the side of a regular star polygon.

Examples

 > $\mathrm{with}\left(\mathrm{plots}\right):$
 > $\mathrm{with}\left(\mathrm{plottools}\right):$
 > $\mathrm{setoptions}\left(\mathrm{axes}="none",\mathrm{scaling}=\mathrm{constrained},\mathrm{size}=\left[300,300\right]\right)$
 > $\mathrm{display}\left(\mathrm{polygonbyname}\left("rectangle",\mathrm{inbox}=\left[16,9\right],\mathrm{color}="Red"\right)\right)$
 > $\mathrm{inscribedBox}≔\mathrm{display}\left(\mathrm{polygonbyname}\left("rectangle",\mathrm{color}="Red",\mathrm{style}=\mathrm{line}\right)\right)$
 > $\mathrm{inscribedCircle}≔\mathrm{display}\left(\mathrm{polygonbyname}\left("circle",\mathrm{color}="Blue",\mathrm{style}=\mathrm{line}\right)\right)$
 > $\mathrm{display}\left(\mathrm{inscribedBox},\mathrm{inscribedCircle},\mathrm{polygonbyname}\left("octagon",\mathrm{color}="Linen"\right)\right)$
 > $\mathrm{display}\left(\mathrm{inscribedBox},\mathrm{inscribedCircle},\mathrm{polygonbyname}\left("hexagon",\mathrm{color}="Linen",\mathrm{rounded}\right)\right)$
 > $\mathrm{display}\left(\mathrm{inscribedBox},\mathrm{inscribedCircle},\mathrm{polygonbyname}\left("hexagon",\mathrm{color}="Linen",\mathrm{rounded}=0.05\right)\right)$
 > $\mathrm{display}\left(\mathrm{inscribedBox},\mathrm{inscribedCircle},\mathrm{polygonbyname}\left(13,\mathrm{star},\mathrm{color}="Linen"\right)\right)$
 > $\mathrm{display}\left(\mathrm{inscribedBox},\mathrm{polygonbyname}\left("7gon",\mathrm{wide},\mathrm{color}="Linen"\right)\right)$
 > $\mathrm{display}\left(\mathrm{polygonbyname}\left("invtriangle",\mathrm{center}=\left[-3,0\right]\right),\mathrm{polygonbyname}\left("triangle",\mathrm{center}=\left[0,0\right]\right),\mathrm{polygonbyname}\left("triangle",\mathrm{center}=\left[3,0\right],\mathrm{rotation}=-90\mathrm{Unit}\left(\mathrm{degrees}\right)\right),\mathrm{size}=\left[600,200\right],\mathrm{style}=\mathrm{line},\mathrm{linestyle}="dash"\right)$

Many Greek names are supported, this shape has 98 sides

 > $\mathrm{display}\left(\mathrm{polygonbyname}\left("enneacontaoctagon",\mathrm{radius}=2\right),\mathrm{axes}=\mathrm{box}\right)$

it looks a lot like a circle

 > $\mathrm{display}\left(\mathrm{polygonbyname}\left("enneacontaoctagon",\mathrm{star}=100,\mathrm{radius}=2,\mathrm{style}=\mathrm{line}\right),\mathrm{axes}=\mathrm{box}\right)$

star can be also used as a shape name for 5 points by default or a number to specify the number of points

 > $\mathrm{display}\left(\mathrm{polygonbyname}\left("star"\right),\mathrm{axes}=\mathrm{box}\right)$
 > $\mathrm{display}\left(\mathrm{polygonbyname}\left("irregular wide 6-star"\right),\mathrm{axes}=\mathrm{box}\right)$

Compatibility

 • The plottools[polygonbyname] command was introduced in Maple 2019.