Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "ObservationDirection.h"
00036
00037
00038
00039 template<typename T>
00040 ObservationDirectionDataPointsFilter<T>::ObservationDirectionDataPointsFilter(const Parameters& params):
00041 PointMatcher<T>::DataPointsFilter("ObservationDirectionDataPointsFilter",
00042 ObservationDirectionDataPointsFilter::availableParameters(), params),
00043 centerX(Parametrizable::get<T>("x")),
00044 centerY(Parametrizable::get<T>("y")),
00045 centerZ(Parametrizable::get<T>("z"))
00046 {
00047 }
00048
00049
00050 template<typename T>
00051 typename PointMatcher<T>::DataPoints
00052 ObservationDirectionDataPointsFilter<T>::filter(const DataPoints& input)
00053 {
00054 DataPoints output(input);
00055 inPlaceFilter(output);
00056 return output;
00057 }
00058
00059
00060 template<typename T>
00061 void ObservationDirectionDataPointsFilter<T>::inPlaceFilter(DataPoints& cloud)
00062 {
00063 const int dim(cloud.features.rows() - 1);
00064 const int featDim(cloud.features.cols());
00065 if (dim != 2 && dim != 3)
00066 {
00067 throw InvalidField(
00068 (boost::format("ObservationDirectionDataPointsFilter: Error, works only in 2 or 3 dimensions, cloud has %1% dimensions.") % dim).str()
00069 );
00070 }
00071
00072 Vector center(dim);
00073 center[0] = centerX;
00074 center[1] = centerY;
00075 if (dim == 3)
00076 center[2] = centerZ;
00077
00078 cloud.allocateDescriptor("observationDirections", dim);
00079 BOOST_AUTO(observationDirections, cloud.getDescriptorViewByName("observationDirections"));
00080
00081 for (int i = 0; i < featDim; ++i)
00082 {
00083
00084 const Vector p(cloud.features.block(0, i, dim, 1));
00085 observationDirections.col(i) = center - p;
00086 }
00087
00088 }
00089
00090 template struct ObservationDirectionDataPointsFilter<float>;
00091 template struct ObservationDirectionDataPointsFilter<double>;
00092