Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This application generate different types of shapes:

-cogwheel polygonal contours
-irregular polygons
-regular polygons
-circles,ellipsis
-stars
-rectangles
-triangles

Main Menu

In the next picture can be seen few of the shapes that can be generated:

Generated Shapes

Drawing of a star:

A user can generate a star with a number of vertices between 3 and 16.
The second property that can be chosen by the user is Depth and it is a value between 10% and 90% of Radius.
The radius represent the distance from star center to the one of the vertices.The center point is randomly generated ,where x and y coordinates are values between -300 and 300.

First image shows a 5 vertices star with a depth of 60%.
Simple Star



Second image shows a 16 vertices start with a depth of 90%.
Complex Star

For simplicity reason the explanation will continue with the first example. The algorithm of star drawing is the next one:
1. It is generated a random number between 60 and 120 which represent the long radius.Distance from star center to a star vertex is considered a long radius.
2. Between every two main vertices, there is a secondary vertex. The short radius is calculated in 3 steps :
a) it is calculated the distance from center to a line that passes through 2 main vertices. Let's call it Dist;
b) the depth in percentage given by user will be calculated as the value from Dist;
c) the short radius will represent the difference between long radius and depth as value.
3.The third step is the generation of circumscribed circle center which is also the center of the star. x and y coordinates are generated as random values between -300 and 300.
4.To generate the polygonal contour is considering a double number of vertices for computing the ( main vertices + secondary vertices). The angle step is computed with next relation:

angle_step=360/(2*nrvertices)

For the 5 vertices star the angle step has 36°.Angles:
0=0*36;
36=1*36;
72=2*36;
...
angle=k*36; where k [0,9)
...
324=9*36;

If k is even number: the point from the polygonal contour will be a main vertex with polar coordinates (long radius,angle). If k is odd number: the point from the polygonal contour will be a secondary vertex with polar coordinates (short radius,angle).

The star will be represented by the polygonal contour that joins all these points ordered by polar coordinate angle. Must be specified that the points added to the contour are given in cartesian coordinates. A previous conversion is necessary.

Drawing triangles

There are 4 ways to generate triangles:
-Scalene triangle
-Isosceles triangle
-Equilateral triangle
-Not random. (In this case the user chooses the coordinates of the vertices. The algorithm implements also a collinearity check to ensure that the 3 points could be the vertices of a triangle)


In the next image can be seen a star and different types of triangles. Shape information

Drawing rectangles


The main properties that can be modified by the user for rectangle generation are : top left corner, width ,height and rotation angle.
The rectangle will be represented as a 4 vertices polygonal contour. The first point will be the top left corner. If the rotation angle is not 0 then the rotation will be done after the top left corner. The other 3 vertices of the rectangle will be computed based on rotation angle, top left corner, width, and height.

Rectangles



Drawing cogwheels


Remark: in the next paragraphs we will refer to the space between two cogwheel teeth as free space

The first parameter that can be selected is the teeth number that the cogwheel will have. It will be between 8 and 60. The second parameter is the cog base radius which is the distance from the circumscribed circle center to the tooth base. The radius can be a number between 100 and 300.

The last editable parameter is the cogwheel teeth height. It is computed as a percentage between 5% and 20% of the cogwheel base radius. It is the distance between the base and top of the cogwheel tooth.
Cogs



The next image shows the way how the algorithm from backend draws cogwheel polygonal contour. It is comparable with the one that draws a star but the repeating pattern it is bit more complex.
A repeating pattern is a pair cogwheel tooth - free space. To explain the creation of polygonal contour it will be used a cogwheel with 4 pairs cogwheel tooth - free space. Note that it is just for theoretical reasons,because the minimal number of pattern pairs that application allow to be created is 8.
Polygonal contour will accept only vertices in cartesian coordinates and because computed points will be in polar coordinates will also be a conversion process.
In this example nr=4 ;as result the sector angle value of a 'pair' will be step_angle=360°/4=90°. It is also necessary to mention that vertices coordinates are relative to the center of circumscribed circle.

First vertex of polygonal contour is P1(r,θ)(base_radius,0°).
Vertex 2 is P2(r,θ)(base_radius+tooth_height,10% of step_angle).
Vertex 3 is P3(r,θ)(base_radius+tooth_height,50% of step_angle).
Vertex 4 is P4(r,θ)(base_radius,60% of step_angle).


If it is considered the pair tooth-space k,where k=0,1,2,... nr-1 than the coordinates for vertices that are part of this pattern are:

First vertex of pattern k is P1(r,θ)(base_radius,k*angle_step).
Vertex 2 of pattern k is P2(r,θ)(base_radius+tooth_height,10% of step_angle+ k*angle_step).
Vertex 3 of pattern k is P3(r,θ)(base_radius+tooth_height,50% of step_angle+k*angle_step).
Vertex 4 of pattern k is P4(r,θ)(base_radius,60% of step_angle+k*angle_step).


Cogs Explanation

About

This is a copy of a private repository

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages