mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/sta-peak.git
synced 2025-06-13 19:25:58 +00:00
Add Quaternion to rotation matrix
This commit is contained in:
parent
86cd951d5e
commit
1393ade57b
@ -8,6 +8,7 @@
|
|||||||
#ifndef STA_PEAK_QUATERNION_HPP
|
#ifndef STA_PEAK_QUATERNION_HPP
|
||||||
#define STA_PEAK_QUATERNION_HPP
|
#define STA_PEAK_QUATERNION_HPP
|
||||||
|
|
||||||
|
#include <sta/math/linalg/matrix.hpp>
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
namespace math {
|
namespace math {
|
||||||
@ -55,11 +56,8 @@ namespace sta
|
|||||||
*/
|
*/
|
||||||
float norm();
|
float norm();
|
||||||
|
|
||||||
/**
|
matrix toRotationMatrix();
|
||||||
* @brief
|
|
||||||
*
|
|
||||||
* @return Quaternion
|
|
||||||
*/
|
|
||||||
Quaternion normalized();
|
Quaternion normalized();
|
||||||
|
|
||||||
Quaternion conjugate();
|
Quaternion conjugate();
|
||||||
|
@ -54,6 +54,23 @@ namespace sta
|
|||||||
return Quaternion(qw, qx, qy, qz).normalized();
|
return Quaternion(qw, qx, qy, qz).normalized();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matrix Quaternion::toRotationMatrix(){
|
||||||
|
|
||||||
|
matrix R = matrix(3, 3);
|
||||||
|
R.set(0, 0, 2 *(w*w + x*x) - 1);
|
||||||
|
R.set(0, 1, 2 *(x*y - w*z));
|
||||||
|
R.set(0, 2, 2 *(x*z + w*y));
|
||||||
|
|
||||||
|
R.set(1, 0, 2 *(x*y + w*z));
|
||||||
|
R.set(1, 1, 2 *(w*w + y*y) - 1);
|
||||||
|
R.set(1, 2, 2 *(y*z - w*x));
|
||||||
|
|
||||||
|
R.set(2, 0, 2 *(x*z - w*y));
|
||||||
|
R.set(2, 1, 2 *(y*z + w*x));
|
||||||
|
R.set(2, 2, 2 *(w*w + z*z) - 1);
|
||||||
|
return R;
|
||||||
|
}
|
||||||
|
|
||||||
Quaternion Quaternion::unit()
|
Quaternion Quaternion::unit()
|
||||||
{
|
{
|
||||||
return Quaternion();
|
return Quaternion();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user