20 #include <Eigen/Geometry> 51 result->point = refPoint;
52 result->quat =
eigenQuatToQuat(source->quat->eigen * objectToRefPoseQuat->eigen);
71 Eigen::Vector3d relativeObjectVector = refToObjectQuat->eigen._transformVector(Eigen::Vector3d::UnitX());
72 Eigen::Vector3d absoluteObjectVector = refPose->quat->eigen._transformVector(relativeObjectVector);
73 result->eigen = refPose->point->eigen + (absoluteObjectVector * radius);
78 getSourcePose(reference, sourcePoint, refToObjectPoseQuat, result);
84 result->point = sourcePoint;
85 result->quat->eigen = reference->quat->eigen * refToObjectPoseQuat->eigen;
90 Eigen::Quaternion<double> rotation = pose->quat->eigen * quat->eigen;
91 Eigen::Vector3d objectPoint = pose->point->eigen;
93 Eigen::Vector3d resultVec = objectPoint + rotation._transformVector(Eigen::Vector3d::UnitX()) * radius;
102 if ( !(vote->radius > -epsylon && vote->radius < epsylon) ||
103 !
quatEqual(selfQuat, *(vote->objectToRefPoseQuat)))
113 if ((refPose->point->eigen - sourcePose->point->eigen).norm() == 0) {
115 sourcePose->point->eigen.x() = (sourcePose->point->eigen.x() + 0.0000001);
117 Eigen::Vector3d objToRefVector = refPose->point->eigen - sourcePose->point->eigen;
118 Eigen::Vector3d refToObjVector = objToRefVector * -1.0;
119 Eigen::Quaternion<double> p = sourcePose->quat->eigen;
120 Eigen::Quaternion<double> r = refPose->quat->eigen;
123 Eigen::Vector3d relativeRefPoint = p.inverse()._transformVector(objToRefVector);
126 Eigen::Quaternion<double> otrp = (p.inverse()) * r;
129 Eigen::Vector3d relativeObjPoint = r.inverse()._transformVector(refToObjVector);
131 Eigen::Quaternion<double> rtop = (r.inverse()) * p;
139 objToRefVector.norm()
157 Eigen::Vector3d firstToSecond = second->point->eigen - first->point->eigen;
158 Eigen::Quaternion<double> firstRotation = first->quat->eigen;
159 return firstRotation.inverse()._transformVector(firstToSecond);
168 return distanceNeighbourThreshold > distance_position
169 && angleNeighbourThreshold > fabs(distance_angle);
183 return (p1->eigen - p2->eigen).norm();
189 return (p1->eigen - p2->eigen).squaredNorm();
194 bool xAbs = fabs(p1->eigen.x() - p2->eigen.x()) < 0.00001;
195 bool yAbs = fabs(p1->eigen.y() - p2->eigen.y()) < 0.00001;
196 bool zAbs = fabs(p1->eigen.z() - p2->eigen.z()) < 0.00001;
197 return (xAbs && yAbs && zAbs);
215 return rad2deg( q1->eigen.angularDistance(q2->eigen) );
219 Eigen::Quaternion<double> rotation = quat->eigen;
220 return rotation._transformVector(viewport);
225 double cosOfAngle = v1.dot(v2) / (v1.norm() * v2.norm());
226 if(cosOfAngle < -1.0) cosOfAngle = -1.0;
227 if(cosOfAngle > 1.0) cosOfAngle = 1.0;
229 return rad2deg(acos(cosOfAngle));
239 bool qxAbs = fabs(q1.
eigen.x() - q2.
eigen.x()) < 0.00001;
240 bool qyAbs = fabs(q1.
eigen.y() - q2.
eigen.y()) < 0.00001;
241 bool qzAbs = fabs(q1.
eigen.z() - q2.
eigen.z()) < 0.00001;
242 bool qwAbs = fabs(q1.
eigen.w() - q2.
eigen.w()) < 0.00001;
243 return (qxAbs && qyAbs && qzAbs && qwAbs);
247 Eigen::Quaternion<double> q;
248 q.setFromTwoVectors(v1, v2);
253 Eigen::Quaternion<double> eq = q->eigen;
254 Eigen::AngleAxisd rollAngle(
deg2rad(alpha), Eigen::Vector3d::UnitX());
255 Eigen::AngleAxisd pitchAngle(
deg2rad(beta), Eigen::Vector3d::UnitY());
256 Eigen::AngleAxisd yawAngle(
deg2rad(gamma), Eigen::Vector3d::UnitZ());
258 Eigen::Quaterniond rot = yawAngle * pitchAngle * rollAngle;
266 Eigen::Vector3d combined(0, 0, 0);
269 combined += quat->eigen._transformVector(Eigen::Vector3d::UnitX());
272 Eigen::Quaternion<double> ret;
273 ret.setFromTwoVectors(Eigen::Vector3d::UnitX(), combined);
277 static bool getNextCombination(
const std::vector<unsigned int>::iterator first, std::vector<unsigned int>::iterator k,
const std::vector<unsigned int>::iterator last)
279 if ((first == last) || (first == k) || (last == k))
282 std::vector<unsigned int>::iterator it1 = first;
283 std::vector<unsigned int>::iterator it2 = last;
295 std::vector<unsigned int>::iterator j = k;
296 while (!(*it1 < *j)) ++j;
297 std::iter_swap(it1,j);
301 std::rotate(it1,j,last);
307 std::rotate(k,it2,last);
311 std::rotate(first,k,last);
318 return rad * (180.0 / M_PI);
322 return deg * (M_PI / 180.0);
335 std::cerr <<
" NaN ";
static double deg2rad(double deg)
boost::shared_ptr< Quaternion > QuaternionPtr
static VoteSpecifierPtr createVoteSpecifier(const PosePtr &sourcePose, const PosePtr &refPose)
static PointPtr vectorToPoint(const Eigen::Vector3d &v)
static double getAngleBetweenQuats(const QuaternionPtr &q1, const QuaternionPtr &q2)
static Eigen::Vector3d getAxisFromQuat(const QuaternionPtr &quat, const Eigen::Vector3d &viewport=Eigen::Vector3d::UnitX())
static QuaternionPtr getQuatFromRPY(const QuaternionPtr &q, const double alpha, const double beta, const double gamma)
static Eigen::Quaternion< double > quatToEigenQuat(const QuaternionPtr &q)
static bool isSelfVote(const VoteSpecifierPtr &vote)
static bool quatEqual(const QuaternionPtr &q1, const QuaternionPtr &q2)
boost::shared_ptr< Point > PointPtr
static PosePtr getPoseFromVote(const PosePtr &source, const VoteSpecifierPtr &vote)
static QuaternionPtr getAveragePose(const std::vector< QuaternionPtr > &poseQuats)
static PointPtr applyQuatAndRadiusToPose(const PosePtr &pose, const QuaternionPtr &quat, double radius)
static bool pointEqual(const PointPtr &p1, const PointPtr &p2)
static double getAngleBetweenAxes(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
static double rad2deg(double rad)
static double getDistanceBetweenPoints(const PointPtr &p1, const PointPtr &p2)
static Eigen::Vector3d getDirectionVector(const PosePtr &first, const PosePtr &second)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Quaternion< double > eigen
static bool poseEqual(const PosePtr &p1, const PosePtr &p2)
static bool getNextCombination(const std::vector< unsigned int >::iterator first, std::vector< unsigned int >::iterator k, const std::vector< unsigned int >::iterator last)
static double getSquaredDistanceBetweenPoints(const PointPtr &p1, const PointPtr &p2)
boost::shared_ptr< VoteSpecifier > VoteSpecifierPtr
static void getSourcePose(const PosePtr &reference, const PointPtr &sourcePoint, const QuaternionPtr &refToObjectPoseQuat, PosePtr &result)
static bool checkIfDoubleNaN(double &c)
static Eigen::Vector3d pointToVector(const PointPtr &p)
boost::shared_ptr< Pose > PosePtr
static Eigen::Quaternion< double > vectorRotationToEigenQuat(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
static Quaternion selfQuat
static void getSourcePoint(const PosePtr &refPose, const QuaternionPtr &refToObjectQuat, double radius, PointPtr &result)
static double constexpr epsylon
static PointPtr getSourcePoint(const PosePtr &refPose, const QuaternionPtr &refToObjectQuat, double radius)
static PosePtr getReferencePose(const PosePtr &source, const PointPtr &refPoint, const QuaternionPtr &objectToRefPoseQuat)
static PosePtr getSourcePose(const PosePtr &reference, const PointPtr &sourcePoint, const QuaternionPtr &refToObjectPoseQuat)
this namespace contains all generally usable classes.
static QuaternionPtr eigenQuatToQuat(const Eigen::Quaternion< double > &q)
static bool sharedNeighborhoodEvaluation(const PosePtr &p1, const PosePtr &p2, double distanceNeighbourThreshold, double angleNeighbourThreshold)
static QuaternionPtr normalize(const QuaternionPtr &quat)
static void getReferencePose(const PosePtr &source, const PointPtr &refPoint, const QuaternionPtr &objectToRefPoseQuat, PosePtr &result)
static bool quatEqual(const Quaternion &q1, const Quaternion &q2)