49 using namespace mrpt::utils;
50 using namespace mrpt::poses;
103 static void getPlanes(
const vector<TPolygon3D> &oldPolys,vector<TPolygonWithPlane> &newPolys);
302 project3D(segment.point1,newXYpose,newSegment.point1);
303 project3D(segment.point2,newXYpose,newSegment.point2);
325 template<
class T>
void project3D(
const T &obj,
const TPlane &newXYPlane,T &newObj) {
344 template<
class T>
void project3D(
const std::vector<T> &objs,
const CPose3D &newXYpose,std::vector<T> &newObjs) {
345 size_t N=objs.size();
347 for (
size_t i=0;i<N;i++)
project3D(objs[i],newXYpose,newObjs[i]);
359 inline void project2D(
const TSegment2D &segment,
const CPose2D &newXpose,TSegment2D &newSegment) {
360 project2D(segment.point1,newXpose,newSegment.point1);
361 project2D(segment.point2,newXpose,newSegment.point2);
380 template<
class T>
void project2D(
const T &obj,
const TLine2D &newXLine,T &newObj) {
398 template<
class T>
void project2D(
const std::vector<T> &objs,
const CPose2D &newXpose,std::vector<T> &newObjs) {
399 size_t N=objs.size();
401 for (
size_t i=0;i<N;i++)
project2D(objs[i],newXpose,newObjs[i]);
435 inline bool intersect(
const TLine2D &r1,
const TPolygon2D &p2,TObject2D &obj) {
484 size_t BASE_IMPEXP intersect(
const std::vector<TPolygon3D> &v1,
const std::vector<TPolygon3D> &v2,CSparseMatrixTemplate<TObject3D> &objs);
489 size_t BASE_IMPEXP intersect(
const std::vector<TPolygon3D> &v1,
const std::vector<TPolygon3D> &v2,std::vector<TObject3D> &objs);
501 size_t M=v1.size(),N=v2.size();
505 for (
size_t i=0;i<M;i++)
for (
size_t j=0;j<M;j++)
if (
intersect(v1[i],v2[j],obj)) objs(i,j)=obj;
513 template<
class T,
class U,
class O>
size_t intersect(
const std::vector<T> &v1,
const std::vector<U> &v2,std::vector<O> objs) {
576 inline double distance(
const TLine2D &l1,
const TPolygon2D &p2) {
691 void BASE_IMPEXP assemblePolygons(
const std::vector<TSegment3D> &segms,std::vector<TPolygon3D> &polys,std::vector<TSegment3D> &remainder);
699 void BASE_IMPEXP assemblePolygons(
const std::vector<TObject3D> &objs,std::vector<TPolygon3D> &polys,std::vector<TObject3D> &remainder);
703 void BASE_IMPEXP assemblePolygons(
const std::vector<TObject3D> &objs,std::vector<TPolygon3D> &polys,std::vector<TSegment3D> &remainder1,std::vector<TObject3D> &remainder2);
758 vector<TPolygonWithPlane> pwp;
774 template<
class T,
class U,
class V>
776 vOut[0]=v0[1]*v1[2]-v0[2]*v1[1];
777 vOut[1]=v0[2]*v1[0]-v0[0]*v1[2];
778 vOut[2]=v0[0]*v1[1]-v0[1]*v1[0];
784 const std::vector<T> &v0,
785 const std::vector<T> &v1,
786 std::vector<T> &v_out )
791 v_out[0] = v0[1]*v1[2] - v0[2]*v1[1];
792 v_out[1] = -v0[0]*v1[2] + v0[2]*v1[0];
793 v_out[2] = v0[0]*v1[1] - v0[1]*v1[0];
797 template<
class VEC1,
class VEC2>
798 inline Eigen::Matrix<double,3,1>
crossProduct3D(
const VEC1 &v0,
const VEC2 &v1) {
799 Eigen::Matrix<double,3,1> vOut;
800 vOut[0]=v0[1]*v1[2]-v0[2]*v1[1];
801 vOut[1]=v0[2]*v1[0]-v0[0]*v1[2];
802 vOut[2]=v0[0]*v1[1]-v0[1]*v1[0];
815 template<
class VECTOR,
class MATRIX>
819 M.set_unsafe(0,0, 0); M.set_unsafe(0,1, -v[2]); M.set_unsafe(0,2, v[1]);
820 M.set_unsafe(1,0, v[2]); M.set_unsafe(1,1, 0); M.set_unsafe(1,2, -v[0]);
821 M.set_unsafe(2,0, -v[1]); M.set_unsafe(2,1, v[0]); M.set_unsafe(2,2, 0);
824 template<
class VECTOR>
840 template<
class VECTOR,
class MATRIX>
844 M.set_unsafe(0,0, 0); M.set_unsafe(0,1, v[2]); M.set_unsafe(0,2, -v[1]);
845 M.set_unsafe(1,0, -v[2]); M.set_unsafe(1,1, 0); M.set_unsafe(1,2, v[0]);
846 M.set_unsafe(2,0, v[1]); M.set_unsafe(2,1, -v[0]); M.set_unsafe(2,2, 0);
849 template<
class VECTOR>
867 template<
class T,
class U>
937 template <
typename T>
943 template <
typename T>
949 template <
typename T>
955 template <
typename T>
963 const double & x1,
const double & y1,
964 const double & x2,
const double & y2,
965 const double & x3,
const double & y3,
966 const double & x4,
const double & y4,
967 double &ix,
double &iy);
972 const double & x1,
const double & y1,
973 const double & x2,
const double & y2,
974 const double & x3,
const double & y3,
975 const double & x4,
const double & y4,
976 float &ix,
float &iy);
981 bool BASE_IMPEXP pointIntoPolygon2D(
const double & px,
const double & py,
unsigned int polyEdges,
const double *poly_xs,
const double *poly_ys );
986 template <
typename T>
996 const T a1 = atan2( v1y - y , v1x - x );
997 const T a2 = atan2( v2y - y , v2x - x );
998 const T a3 = atan2( v3y - y , v3x - x );
999 const T a4 = atan2( v4y - y , v4x - x );
1005 if (
sign(da1)!=
sign(da2))
return false;
1008 if (
sign(da2)!=
sign(da3))
return false;
1026 const double & p1_x,
const double & p1_y,
const double & p1_z,
1027 const double & p2_x,
const double & p2_y,
const double & p2_z,
1028 const double & p3_x,
const double & p3_y,
const double & p3_z,
1029 const double & p4_x,
const double & p4_y,
const double & p4_z,
1030 double &x,
double &y,
double &z,
1040 const double & R1_x_min,
const double & R1_x_max,
1041 const double & R1_y_min,
const double & R1_y_max,
1042 const double & R2_x_min,
const double & R2_x_max,
1043 const double & R2_y_min,
const double & R2_y_max,
1044 const double & R2_pose_x,
1045 const double & R2_pose_y,
1046 const double & R2_pose_phi );
1084 if (dx==0 && dy==0 && dz==0)
1091 T n = sqrt(n_xy+
square(dz));
1098 if (fabs(dx)>1e-4 || fabs(dy)>1e-4)
1100 P(0,1) = -dy / n_xy;
1133 template <
typename VECTOR_LIKE,
typename Precision,
typename MATRIX_LIKE>
1134 inline void rodrigues_so3_exp(
const VECTOR_LIKE& w,
const Precision A,
const Precision B,MATRIX_LIKE & R)
1140 const Precision wx2 = (Precision)w[0]*w[0];
1141 const Precision wy2 = (Precision)w[1]*w[1];
1142 const Precision wz2 = (Precision)w[2]*w[2];
1143 R(0,0) = 1.0 - B*(wy2 + wz2);
1144 R(1,1) = 1.0 - B*(wx2 + wz2);
1145 R(2,2) = 1.0 - B*(wx2 + wy2);
1148 const Precision a = A*w[2];
1149 const Precision b = B*(w[0]*w[1]);
1154 const Precision a = A*w[1];
1155 const Precision b = B*(w[0]*w[2]);
1160 const Precision a = A*w[0];
1161 const Precision b = B*(w[1]*w[2]);