![]() Also applicable to any regular polygon 1st Year Engineering Drawing 6 years ago Wimmas EGD Benny Auguste Max Bui Ricardo Goulbourne. We are going to use a path that allows to set the coordinates before drawing them and when finished we use stroke() to draw only the border line. 2.6a-Simpler method to draw a regular Pentagon or a Hexagon. ![]() Cube coordinates Axial coordinates Offset coordinates As with cube and axial coordinates, well build a table of the numbers we need to add to coland row. In order to draw a regular hexagon we define a function named drawHexagon(x,y) being x and y the center point. We might also want to calculate the 6 diagonal hexes. Notice the angles are needed to be expressed in radians (360º = 2π rad) const a = 2 * Math.PI / 6 In an index.html file we set the minimum required fields for a HTML canvas: Īnd a main.js file: const canvas = document.getElementById('canvas') Īs far as we know, we are going to set up the angle and the size of the hexagon as constants. Use a ruler and a protractor to draw a perfect hexagon. In a pinch, consider simply tracing an existing picture of a hexagon. Look at pictures of hexagons to get a better idea of what you're drawing. These are the resulting vertexes:Īs this point we can start a new project to put in practice all we have seen. Divide it into four parts with lines from top to bottom and from right to left. Loosely-defined, a hexagon is any polygon with six sides, but a regular hexagon features six equal sides and six equal angles. Notice that the most-right and most-left vertex coincide with what we have expected due to sin0º = 0, cos0º = 1, cos180º = -1 and sin0º = 0. Then the rest comes as a multiple of 60º as 120º, 180º, 240º, 300º and 360º which is equal to 0º again. g.drawPolygon - making pentagon, hexagon, octagon etc 843806 edited is there any code somewhere on how to draw pentagons, hexagons, octagons etc using drawPolygon or any other function I have tried but my maths is not so good. In summary, putting all together the second vertex coordinates are ( rcos60º, rsin60º). From the first equation we can say that a = c sinα and b = c cosα. ![]() For this case, the angle formed by each vertex with the horizontal axis is equal by dividing the circumference by the number of sides (360º / 6 = 60º) and we also know that the hypotenuse is equal to the radius of the circumference r. It is very useful to know any side of the triangle if you know one of its other sides and the angle it forms.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |