warp_point_rigid.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Point Cloud Library (PCL) - www.pointclouds.org
00005  *  Copyright (c) 2010, Willow Garage, Inc.
00006  *  Copyright (c) 2012-, Open Perception, Inc.
00007  *
00008  *  All rights reserved.
00009  *
00010  *  Redistribution and use in source and binary forms, with or without
00011  *  modification, are permitted provided that the following conditions
00012  *  are met:
00013  *
00014  *   * Redistributions of source code must retain the above copyright
00015  *     notice, this list of conditions and the following disclaimer.
00016  *   * Redistributions in binary form must reproduce the above
00017  *     copyright notice, this list of conditions and the following
00018  *     disclaimer in the documentation and/or other materials provided
00019  *     with the distribution.
00020  *   * Neither the name of the copyright holder(s) nor the names of its
00021  *     contributors may be used to endorse or promote products derived
00022  *     from this software without specific prior written permission.
00023  *
00024  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00025  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00026  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00027  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00028  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00029  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00030  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00031  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00033  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00034  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00035  *  POSSIBILITY OF SUCH DAMAGE.
00036  *
00037  * $Id$
00038  *
00039  */
00040 
00041 #ifndef PCL_WARP_POINT_RIGID_H_
00042 #define PCL_WARP_POINT_RIGID_H_
00043 
00044 #include <pcl/registration/eigen.h>
00045 
00046 namespace pcl
00047 {
00048   namespace registration
00049   {
00056     template <typename PointSourceT, typename PointTargetT, typename Scalar = float>
00057     class WarpPointRigid
00058     {
00059       public:
00060         typedef Eigen::Matrix<Scalar, 4, 4> Matrix4;
00061         typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> VectorX;
00062         typedef Eigen::Matrix<Scalar, 4, 1> Vector4;
00063 
00064         typedef boost::shared_ptr<WarpPointRigid<PointSourceT, PointTargetT, Scalar> > Ptr;
00065         typedef boost::shared_ptr<const WarpPointRigid<PointSourceT, PointTargetT, Scalar> > ConstPtr;
00066 
00070         WarpPointRigid (int nr_dim)
00071           : nr_dim_ (nr_dim)
00072           , transform_matrix_ (Matrix4::Zero ())
00073         {
00074           transform_matrix_ (3, 3) = 1.0;
00075         };
00076 
00078         virtual ~WarpPointRigid () {};
00079 
00083         virtual void 
00084         setParam (const VectorX& p) = 0;
00085 
00090         inline void 
00091         warpPoint (const PointSourceT& pnt_in, PointSourceT& pnt_out) const
00092         {
00093           pnt_out.x = static_cast<float> (transform_matrix_ (0, 0) * pnt_in.x + transform_matrix_ (0, 1) * pnt_in.y + transform_matrix_ (0, 2) * pnt_in.z + transform_matrix_ (0, 3));
00094           pnt_out.y = static_cast<float> (transform_matrix_ (1, 0) * pnt_in.x + transform_matrix_ (1, 1) * pnt_in.y + transform_matrix_ (1, 2) * pnt_in.z + transform_matrix_ (1, 3));
00095           pnt_out.z = static_cast<float> (transform_matrix_ (2, 0) * pnt_in.x + transform_matrix_ (2, 1) * pnt_in.y + transform_matrix_ (2, 2) * pnt_in.z + transform_matrix_ (2, 3));
00096           //pnt_out.getVector3fMap () = transform_matrix_.topLeftCorner (3, 3) * 
00097           //                            pnt_in.getVector3fMap () + 
00098           //                            transform_matrix_.block (0, 3, 3, 1);
00099           //pnt_out.data[3] = pnt_in.data[3];
00100         }
00101 
00106         inline void 
00107         warpPoint (const PointSourceT& pnt_in, Vector4& pnt_out) const
00108         {
00109           pnt_out[0] = static_cast<Scalar> (transform_matrix_ (0, 0) * pnt_in.x + transform_matrix_ (0, 1) * pnt_in.y + transform_matrix_ (0, 2) * pnt_in.z + transform_matrix_ (0, 3));
00110           pnt_out[1] = static_cast<Scalar> (transform_matrix_ (1, 0) * pnt_in.x + transform_matrix_ (1, 1) * pnt_in.y + transform_matrix_ (1, 2) * pnt_in.z + transform_matrix_ (1, 3));
00111           pnt_out[2] = static_cast<Scalar> (transform_matrix_ (2, 0) * pnt_in.x + transform_matrix_ (2, 1) * pnt_in.y + transform_matrix_ (2, 2) * pnt_in.z + transform_matrix_ (2, 3));
00112           pnt_out[3] = 0.0;
00113         }
00114 
00116         inline int 
00117         getDimension () const { return (nr_dim_); }
00118 
00120         inline const Matrix4& 
00121         getTransform () const { return (transform_matrix_); }
00122         
00123       public:
00124         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00125 
00126       protected:
00127         int nr_dim_;
00128         Matrix4 transform_matrix_;
00129     };
00130   } // namespace registration
00131 } // namespace pcl
00132 
00133 #endif


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:38:43