# Quaternions and Euler Rotations Exploration

**URL:** <https://discourse.processing.org/t/quaternions-and-euler-rotations-exploration/11262>\
**Category:** Gallery\
**Created:** [May 15, 2019, 11:07am UTC](https://discourse.processing.org/t/quaternions-and-euler-rotations-exploration/11262 "2019-05-15T11:07:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [May 15, 2019, 11:07am UTC](https://discourse.processing.org/t/quaternions-and-euler-rotations-exploration/11262/1 "2019-05-15T11:07:07Z")

</div>

Hello,

I did an exploration of rotations with quaternions and Euler angles and sharing the “bare bones” code I wrote.

The original project (a year ago) got out of hand and I really need to clean up the code and references and this was a start.

This code was written to test formulas from:  
[http://www.euclideanspace.com/maths/geometry/rotations/conversions/index.htm](http://www.euclideanspace.com/maths/geometry/rotations/conversions/index.htm)

This program:

1. Generates Euler angles with keyboard control
2. Euler angles are converted to quaternions
3. quaternions are converted back to Euler angles
4. Euler angles are used to rotate a shape

Later I replaced 1 and 2 with serial data (quaternions) from a BNO055 sensor; there was a lot more involved in doing this. 🙂

Code:  
[https://github.com/glvjr/BNO055](https://github.com/glvjr/BNO055)

Sensor:

> **[Adafruit BNO055 Absolute Orientation Sensor](https://learn.adafruit.com/adafruit-bno055-absolute-orientation-sensor/overview)**
>
> The BNO055 is everything you've always wanted for AHRS or orientation data in a single chip. On chip sensor fusion algorithms, quaternion, euler and vector output, and "just works" data output. Stop meddling with mind-numbing fusion algorithms, and...

Example video of final project (the one I posted is only keyboard and “minimal”):

[![](https://img.youtube.com/vi/6dVMDsV1SEo/maxresdefault.jpg "BNO055 Sensor from Arduino to Processing") ](https://www.youtube.com/watch?v=6dVMDsV1SEo)

Enjoy!

🙂

---

<div class="post-metadata">

**Author:** ![HackinHarry](https://avatars.discourse-cdn.com/v4/letter/h/3e96dc/32.png) [@HackinHarry](https://discourse.processing.org/u/HackinHarry)\
**Post date:** [July 17, 2020, 5:55am UTC](https://discourse.processing.org/t/quaternions-and-euler-rotations-exploration/11262/2 "2020-07-17T05:55:30Z")

</div>

That’s beautiful.

I’m using this code from [https://code.google.com/archive/p/digital-ahrs/downloads](https://code.google.com/archive/p/digital-ahrs/downloads)  
to display the data but I need what you did with quaternions and euler angles to turn it. I’m using an HMC5883L for the magnetometer data.
