00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00033 #ifndef _TRANSFORMS_H 00034 #define _TRANSFORMS_H 00035 00036 /* SECTION:transforms*/ 00037 00056 #ifdef __cplusplus 00057 extern "C" { 00058 #endif 00059 00060 /* 00061 When composing rotations, the resulting quaternion represents 00062 first rotating by b, then rotation by a. 00063 */ 00064 void rot_quat_mult (double c[4], const double a[4], const double b[4]); 00065 //void rot_quat_rotate (const double quat[4], double v[3]); 00066 void rot_quat_rotate (const double *, double *); 00067 //void rot_quat_rotate_rev (const double quat[4], double v[3]); 00068 void rot_quat_rotate_rev (const double *, double *); 00069 // formerly: rot_quat_to_matrix 00070 int rot_quat_to_matrix(const double quat[4], double rot[9]); 00071 // formerly: rot_matrix_to_quat 00072 int rot_matrix_to_quat(const double rot[9], double quat[4]); 00073 int rot_quat_pos_to_matrix(const double quat[4], const double pose[3], double m[16]); 00074 00075 /* 00076 populates a quaternion so that it represents a rotation of theta radians 00077 about the axis <x,y,z> 00078 */ 00079 void rot_angle_axis_to_quat (double theta, const double axis[3], double q[4]); 00080 void rot_quat_to_angle_axis (const double q[4], double *theta, double axis[3]); 00081 00082 /* 00083 * converts a rotation from RPY representation (radians) into unit quaternion 00084 * representation 00085 * 00086 * rpy[0] = roll 00087 * rpy[1] = pitch 00088 * rpy[2] = yaw 00089 */ 00090 void rot_roll_pitch_yaw_to_quat(const double rpy[3], double q[4]); 00091 00092 /* 00093 * converts a rotation from unit quaternion representation to RPY 00094 * representation. Resulting values are in radians. 00095 * 00096 * If any of roll, pitch, or yaw are NULL, then they are not set. 00097 * 00098 * rpy[0] = roll 00099 * rpy[1] = pitch 00100 * rpy[2] = yaw 00101 */ 00102 void rot_quat_to_roll_pitch_yaw (const double q[4], double rpy[3]); 00103 /* These doesn't truly belong with the quaternion functions, but are useful and sort of fits in here. */ 00104 void rot_roll_pitch_yaw_to_angle_axis (const double rpy[3], double *angle, double axis[3]); 00105 void rot_angle_axis_to_roll_pitch_yaw (double angle, const double axis[3], double rpy[3]); 00106 // runs some sanity checks 00107 int rot_quaternion_test(); 00108 00109 #ifdef __cplusplus 00110 } 00111 #endif 00112 00113 #endif 00114