9/11/2023 0 Comments X sides polygon![]() Local angle_increment = 2 * math. computes coordinates for n-sided, regular polygon of given radius and start angleįunction polypoints(sides, radius, start) The coordinates returned can be used to initialize an OpenGL GL_LINE_LOOP mesh primitive. It just prints out the coordinates, but you're of course free to return the coordinates in an array / table. If you want to be hardcore about it, pre-generate all the n-gons you need and load them into vertex buffers.Īs an aside, here's the above solution in Lua. Usually a regular n-gon can be initialized and the hardware scaling of OpenGL used to scale / transform it for any particular instance. For the guy who suggested that you could simplify the calculations by using complex numbers, nearly all math libraries have table-based cos() and sin() routines with efficient interpolation so there's no need to delve into relatively obscure solutions. The "for n_sides:" answer is the easiest. ![]() The language I'm using is a Visual Basic-like language that has almost no graphics primitives other than line drawing. If you have to answer with a math formula, do it in a computer language so I can read it, even in C or C++ I can figure it out, but I don't know how to read mathematical notation. Prefer answers in a visual basic (or even old style Microsoft/Atari/Commodore BASIC) or a human readable set of steps in English. continue until the angle=360 divided by that number.Īssuming that my assumptions are correct, the main thing is to understand how to compute the x,y points.divide 360 by the number of sides, move that distance and draw the next line from the first x,y point.Let’s see some properties of irregular polygons. somehow calculate the x,y position at that distance from the center(how?) Here are a few examples showing the names of irregular polygons and the number of sides: Properties of Irregular Polygons.pick an angle to start from a radius and a center point.Can someone give me some code examples that don't use preexisting functions that draw polygons? I want to understand the process, which I assume is something like this: Total interior angles = (n - 2)180°, where n is the number of sides.I have been trying to figure out how to write a simple program to compute the x,y points for creating a regular polygon of n sides. The number of triangles is always two less than the number of sides. To determine the total sum of the interior angles, you need to multiply the number of triangles that form the shape by 180°. Step 1: Using the name, determine how many sides the shape has.Ī polygon with 23 sides has a total of 3780 degrees. Step 1: Determine the number of sides in a dodecagon.Įxample 3: How many degrees are in a 23-gon?Īlthough polygons do have official names, many mathematicians refer to some of the many sided figures by just using the number of sides followed by "gon." Step 1: Determine the number of sides in a nonagon.Įxample 2: How many degrees are in a dodecagon? And the number of triangles is 2 less than the number of sides.Įxample 1: How many degrees are in a nonagon? ![]() The number of degrees inside the polygon can be determined by multiplying the number of triangles in the shape by 180 degrees. Notice that the number of triangles is 2 less than the number of sides in each example. Let's take a look at some of the polygons to find a pattern. However, do you know how many degrees are in a pentagon or a dodecagon? You may already know that triangles have 180° and quadrilaterals have 360°. The Sum of the Interior Angles in a Polygon ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |