| 
									
										
										
										
											2010-10-14 12:54:38 +08:00
										 |  |  | /* ----------------------------------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * GTSAM Copyright 2010, Georgia Tech Research Corporation,  | 
					
						
							|  |  |  |  * Atlanta, Georgia 30332-0415 | 
					
						
							|  |  |  |  * All Rights Reserved | 
					
						
							|  |  |  |  * Authors: Frank Dellaert, et al. (see THANKS for the full author list) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * See LICENSE for the license information | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  * -------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * StereoPoint2.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *  Created on: Jan 26, 2010 | 
					
						
							|  |  |  |  *      Author: dellaert | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef STEREOPOINT2_H_
 | 
					
						
							|  |  |  | #define STEREOPOINT2_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							| 
									
										
										
										
											2010-08-20 01:23:19 +08:00
										 |  |  | #include <gtsam/base/Vector.h>
 | 
					
						
							|  |  |  | #include <gtsam/base/Testable.h>
 | 
					
						
							|  |  |  | #include <gtsam/base/Lie.h>
 | 
					
						
							|  |  |  | #include <gtsam/geometry/Point2.h>
 | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace gtsam { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/**
 | 
					
						
							|  |  |  | 	 * A 2D stereo point, v will be same for rectified images | 
					
						
							|  |  |  | 	 */ | 
					
						
							|  |  |  | 	class StereoPoint2: Testable<StereoPoint2>, Lie<StereoPoint2> { | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 	public: | 
					
						
							|  |  |  | 		static const size_t dimension = 3; | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 	private: | 
					
						
							|  |  |  | 		double uL_, uR_, v_; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** default constructor */ | 
					
						
							|  |  |  | 		StereoPoint2() : | 
					
						
							|  |  |  | 			uL_(0), uR_(0), v_(0) { | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** constructor */ | 
					
						
							|  |  |  | 		StereoPoint2(double uL, double uR, double v) : | 
					
						
							|  |  |  | 			uL_(uL), uR_(uR), v_(v) { | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** print */ | 
					
						
							|  |  |  | 		void print(const std::string& s) const { | 
					
						
							|  |  |  | 			std::cout << s << "(" << uL_ << ", " << uR_ << ", " << v_ << ")" | 
					
						
							|  |  |  | 					<< std::endl; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** equals */ | 
					
						
							|  |  |  | 		bool equals(const StereoPoint2& q, double tol) const { | 
					
						
							|  |  |  | 			return (fabs(uL_ - q.uL_) < tol && fabs(uR_ - q.uR_) < tol && fabs(v_ | 
					
						
							|  |  |  | 					- q.v_) < tol); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 	    /** dimension of the variable - used to autodetect sizes */ | 
					
						
							|  |  |  | 	    inline static size_t Dim() { return dimension; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** Lie requirements */ | 
					
						
							|  |  |  | 		inline size_t dim() const { return dimension; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 		/** convert to vector */ | 
					
						
							|  |  |  | 		Vector vector() const { | 
					
						
							|  |  |  | 			return Vector_(3, uL_, uR_, v_); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** add two stereo points */ | 
					
						
							|  |  |  | 		StereoPoint2 operator+(const StereoPoint2& b) const { | 
					
						
							|  |  |  | 			return StereoPoint2(uL_ + b.uL_, uR_ + b.uR_, v_ + b.v_); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/** subtract two stereo points */ | 
					
						
							|  |  |  | 		StereoPoint2 operator-(const StereoPoint2& b) const { | 
					
						
							|  |  |  | 			return StereoPoint2(uL_ - b.uL_, uR_ - b.uR_, v_ - b.v_); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/*
 | 
					
						
							|  |  |  | 		 * convenient function to get a Point2 from the left image | 
					
						
							|  |  |  | 		 */ | 
					
						
							|  |  |  | 		inline Point2 point2(){ | 
					
						
							|  |  |  | 			return Point2(uL_, v_); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		/** "Compose", just adds the coordinates of two points. */ | 
					
						
							|  |  |  | 		inline StereoPoint2 compose(const StereoPoint2& p1) const { | 
					
						
							|  |  |  | 			return *this + p1; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		/** inverse */ | 
					
						
							|  |  |  | 		inline StereoPoint2 inverse() const { | 
					
						
							|  |  |  | 			return StereoPoint2()- (*this); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		/** Exponential map around identity - just create a Point2 from a vector */ | 
					
						
							|  |  |  | 		static inline StereoPoint2 Expmap(const Vector& d) { | 
					
						
							|  |  |  | 			return StereoPoint2(d(0), d(1), d(2)); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 		/** Log map around identity - just return the Point2 as a vector */ | 
					
						
							|  |  |  | 		static inline Vector Logmap(const StereoPoint2& p) { | 
					
						
							|  |  |  | 			return p.vector(); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2010-08-27 03:55:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	    /** default implementations of binary functions */ | 
					
						
							|  |  |  | 	    inline StereoPoint2 expmap(const Vector& v) const { | 
					
						
							|  |  |  | 	    	return gtsam::expmap_default(*this, v); | 
					
						
							|  |  |  | 	    } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	    inline Vector logmap(const StereoPoint2& p2) const { | 
					
						
							|  |  |  | 	    	return gtsam::logmap_default(*this, p2); | 
					
						
							|  |  |  | 	    } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	    inline StereoPoint2 between(const StereoPoint2& p2) const { | 
					
						
							|  |  |  | 	    	return gtsam::between_default(*this, p2); | 
					
						
							|  |  |  | 	    } | 
					
						
							| 
									
										
										
										
											2010-08-20 04:03:06 +08:00
										 |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2010-08-09 04:23:38 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* STEREOPOINT2_H_ */
 |