
SPI slave program to enable communication between the FPGA and the STM32L432 board.
Diff: Quaternions.cpp
- Revision:
- 5:155d224d855c
- Parent:
- 4:e36c7042d3bb
- Child:
- 6:0ebecfecadc9
diff -r e36c7042d3bb -r 155d224d855c Quaternions.cpp --- a/Quaternions.cpp Sat Feb 23 01:20:08 2019 +0000 +++ b/Quaternions.cpp Sun Feb 24 16:49:06 2019 +0000 @@ -410,4 +410,31 @@ return EulerAngles; } +//----------------------------------------------------------------------------------------------------------------// + + + +//----------------------------------------------------------------------------------------------------------------// +Quaternion euler2Quaternion(Quaternion Q) +{ + + + + // Abbreviations for the various angular functions + double cy = cosf(Q.z * 0.5f); + double sy = sinf(Q.z * 0.5f); + double cp = cosf(Q.y * 0.5f); + double sp = sinf(Q.y * 0.5f); + double cr = cosf(Q.x * 0.5f); + double sr = sinf(Q.x * 0.5f); + + Quaternion q; + q.w = cy * cp * cr + sy * sp * sr; + q.x = cy * cp * sr - sy * sp * cr; + q.y = sy * cp * sr + cy * sp * cr; + q.z = sy * cp * cr - cy * sp * sr; + + return q; + +} //----------------------------------------------------------------------------------------------------------------// \ No newline at end of file