# Arduino Library for the Stewart Flight Simulator Platform — Part 2

Part 2 demonstrates the techniques used for finding the centre of gravity of our top and bottom hexagonal platforms and how to calculate the co-ordinates of the connection points on each edge. This step is glossed over by everyone! It is not until you try to actually code the formulaes that you realise that you need the co-ordinates of the twelve connection points on both platforms.

## Finding the Centroid / Centre of Gravity (COG)

In order to apply the inverse kinematic transformations described in Part 3, we need the co-ordinates of the connection points on the top and bottom platforms. We will start with the top platform because that is straight forward. Finding the vertices of our irregular hexagonal platform, allows us to calculate the **centroid** (the centre of mass of a geometric object of uniform density). The centroid is where the x, y, and z axes have their origin, when performing the inverse kinematic.

Figure 9 illustrates the problem, all measurements are in millimetres, and the angles are in degrees. We need to find the length of the sides of triangles **A** and **B**. Trigonometry to the rescue! For **A**:

`cos 60 = x/40`

or `x = 40 cos 60 = 20`

`sin 60 = y/40`

or `y = 40 sin 60 = 34.64`