mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-24 12:23:34 +08:00
Quaternion add copyTo
This commit is contained in:
+30
-1
@@ -1,4 +1,33 @@
|
|||||||
build*/
|
|
||||||
*.orig
|
*.orig
|
||||||
*.swp
|
*.swp
|
||||||
|
astyle/
|
||||||
|
build*/
|
||||||
|
cmake_install.cmake
|
||||||
|
CMakeCache.txt
|
||||||
|
CMakeFiles/
|
||||||
|
CPackConfig.cmake
|
||||||
|
CPackSourceConfig.cmake
|
||||||
|
CTestTestfile.cmake
|
||||||
|
Makefile
|
||||||
|
test/attitude
|
||||||
|
test/cmake_install.cmake
|
||||||
|
test/CMakeFiles/
|
||||||
|
test/CTestTestfile.cmake
|
||||||
|
test/filter
|
||||||
|
test/hatvee
|
||||||
|
test/helper
|
||||||
|
test/integration
|
||||||
|
test/inverse
|
||||||
|
test/Makefile
|
||||||
|
test/matrixAssignment
|
||||||
|
test/matrixMult
|
||||||
|
test/matrixScalarMult
|
||||||
|
test/setIdentity
|
||||||
|
test/slice
|
||||||
|
test/squareMatrix
|
||||||
|
test/transpose
|
||||||
|
test/vector
|
||||||
|
test/vector2
|
||||||
|
test/vector3
|
||||||
|
test/vectorAssignment
|
||||||
Testing/
|
Testing/
|
||||||
|
|||||||
@@ -253,6 +253,20 @@ public:
|
|||||||
q = q * scalar;
|
q = q * scalar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy quaternion to a float array
|
||||||
|
*
|
||||||
|
* @param dst array of 4 floats
|
||||||
|
*/
|
||||||
|
void copyTo(float (&dst)[4])
|
||||||
|
{
|
||||||
|
const Quaternion &q = *this;
|
||||||
|
dst[0] = q(0);
|
||||||
|
dst[1] = q(1);
|
||||||
|
dst[2] = q(2);
|
||||||
|
dst[3] = q(3);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the derivative of q_12 when
|
* Computes the derivative of q_12 when
|
||||||
* rotated with angular velocity expressed in frame 2
|
* rotated with angular velocity expressed in frame 2
|
||||||
|
|||||||
@@ -343,6 +343,17 @@ int main()
|
|||||||
q = Quatf(0,0,0,1); // 180 degree rotation around the z axis
|
q = Quatf(0,0,0,1); // 180 degree rotation around the z axis
|
||||||
R = Dcmf(q);
|
R = Dcmf(q);
|
||||||
TEST(isEqual(q, Quatf(R)));
|
TEST(isEqual(q, Quatf(R)));
|
||||||
|
|
||||||
|
|
||||||
|
// Quaternion copyTo
|
||||||
|
q = Quatf(1, 2, 3, 4);
|
||||||
|
float dst[4] = {};
|
||||||
|
q.copyTo(dst);
|
||||||
|
TEST(fabsf(q(0) - dst[0]) < eps);
|
||||||
|
TEST(fabsf(q(1) - dst[1]) < eps);
|
||||||
|
TEST(fabsf(q(2) - dst[2]) < eps);
|
||||||
|
TEST(fabsf(q(3) - dst[3]) < eps);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */
|
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */
|
||||||
|
|||||||
Reference in New Issue
Block a user