1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #pragma once 17 18 #include <Eigen/Geometry> 19 20 namespace android { 21 namespace media { 22 23 /** 24 * Converts a rotation vector to an equivalent quaternion. 25 * The rotation vector is given as a 3-vector whose direction represents the rotation axis and its 26 * magnitude the rotation angle (in radians) around that axis. 27 */ 28 Eigen::Quaternionf rotationVectorToQuaternion(const Eigen::Vector3f& rotationVector); 29 30 /** 31 * Converts a quaternion to an equivalent rotation vector. 32 * The rotation vector is given as a 3-vector whose direction represents the rotation axis and its 33 * magnitude the rotation angle (in radians) around that axis. 34 */ 35 Eigen::Vector3f quaternionToRotationVector(const Eigen::Quaternionf& quaternion); 36 37 /** 38 * Returns a quaternion representing a rotation around the X-axis with the given amount (in 39 * radians). 40 */ 41 Eigen::Quaternionf rotateX(float angle); 42 43 /** 44 * Returns a quaternion representing a rotation around the Y-axis with the given amount (in 45 * radians). 46 */ 47 Eigen::Quaternionf rotateY(float angle); 48 49 /** 50 * Returns a quaternion representing a rotation around the Z-axis with the given amount (in 51 * radians). 52 */ 53 Eigen::Quaternionf rotateZ(float angle); 54 55 } // namespace media 56 } // namespace android 57