Calculating overall acceleration

Acceleration is a vector quantity, so it has a magnitude (size, length) and a direction. To get the overall magnitude, irrespective of orientation, we need to do a simple calculation.

If you want to get the overall acceleration with only x and y axes (known as 2D acceleration), you can calculate the magnitude (length) of the result with Pythagoras' rule:

Figure 6.15 represents 2D acceleration using Pythagoras' rule:

Figure 6.15: Representing 2D acceleration using Pythagoras' rule

If you want to get the overall acceleration using three axes (known as 3D acceleration), the magnitude can be calculated as:

Listing 6.2 shows sample code that can be run on Raspberry Pi to calculate the 2D and 3D magnitude:

Listing 6.2: Calculating 2D and 3D magnitude
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.14.63