transform.h

Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2010, Willow Garage, Inc.
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of Willow Garage, Inc. nor the names of its
00018  *     contributors may be used to endorse or promote products derived
00019  *     from this software without specific prior written permission.
00020  *
00021  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032  *  POSSIBILITY OF SUCH DAMAGE.
00033  *
00034  */
00035 
00036 #ifndef PCL_TRANSFORM_H_
00037 #define PCL_TRANSFORM_H_
00038 
00039 #include <Eigen/Geometry>
00040 
00048 namespace pcl
00049 {
00057   inline void
00058   getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis, const Eigen::Vector3f& y_direction,
00059                              Eigen::Affine3f& transformation);
00060   
00068   inline Eigen::Affine3f
00069   getTransFromUnitVectorsZY (const Eigen::Vector3f& z_axis, const Eigen::Vector3f& y_direction);
00070  
00078   inline void
00079   getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis, const Eigen::Vector3f& y_direction,
00080                              Eigen::Affine3f& transformation);
00081 
00089   inline Eigen::Affine3f
00090   getTransFromUnitVectorsXY (const Eigen::Vector3f& x_axis, const Eigen::Vector3f& y_direction);
00091   
00093   inline void
00094   getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction, const Eigen::Vector3f& z_axis,
00095                                        Eigen::Affine3f& transformation);
00096   
00098   inline Eigen::Affine3f
00099   getTransformationFromTwoUnitVectors (const Eigen::Vector3f& y_direction, const Eigen::Vector3f& z_axis);
00100 
00109   inline void
00110   getTransformationFromTwoUnitVectorsAndOrigin (const Eigen::Vector3f& y_direction, const Eigen::Vector3f& z_axis,
00111                                                 const Eigen::Vector3f& origin, Eigen::Affine3f& transformation);
00112 
00118   inline std::ostream&
00119   operator<< (std::ostream& os, const Eigen::Affine3f& m)
00120   {
00121     os << "{(" << m (0,0) << "," <<m (0,1) << "," << m (0,2) << "," << m (0,3)
00122        << ")(" << m (1,0) << "," <<m (1,1) << "," << m (1,2) << "," << m (1,3)
00123        << ")(" << m (2,0) << "," <<m (2,1) << "," << m (2,2) << "," << m (2,3)
00124        << ")(" << m (3,0) << "," <<m (3,1) << "," << m (3,2) << "," << m (3,3) << ")}";
00125     return (os);
00126   }
00127 
00133   inline Eigen::Affine3f
00134   getRotation (const Eigen::Affine3f& transformation);
00135 
00141   inline Eigen::Vector3f
00142   getTranslation (const Eigen::Affine3f& transformation);
00143 
00149   inline void
00150   getInverse (const Eigen::Affine3f& transformation, Eigen::Affine3f& inverse_transformation);
00151 
00157   inline Eigen::Affine3f getInverse (const Eigen::Affine3f& transformation);
00158 
00165   template <typename PointType> inline PointType 
00166   transformXYZ (const Eigen::Affine3f& transformation, const PointType& point);
00167   
00174   template <typename PointCloudType> inline void
00175   getTransformedPointCloud (const PointCloudType& input, const Eigen::Affine3f& transformation,
00176                             PointCloudType& output);
00177   
00185   inline void
00186   getEulerAngles (const Eigen::Affine3f& t, float& roll, float& pitch, float& yaw);
00187 
00198   inline void
00199   getTranslationAndEulerAngles (const Eigen::Affine3f& t, float& x, float& y, float& z,
00200                                 float& roll, float& pitch, float& yaw);
00201 
00212   inline void
00213   getTransformation (float x, float y, float z, float roll, float pitch, float yaw, Eigen::Affine3f& t);
00214 
00225   inline Eigen::Affine3f
00226   getTransformation (float x, float y, float z, float roll, float pitch, float yaw);
00227   
00233   template <typename Derived> void
00234   saveBinary (const Eigen::MatrixBase<Derived>& matrix, std::ostream& file);
00235 
00241   template <typename Derived> void
00242   loadBinary (Eigen::MatrixBase<Derived>& matrix, std::istream& file);
00243   
00244 }  // namespace end
00246 #include "pcl/common/impl/transform.hpp"
00247 
00248 #endif  //#ifndef PCL_NORMS_H_