Edge.h
Go to the documentation of this file.
00001 #ifndef __Edge_H__
00002 #define __Edge_H__
00003 
00004 #include "Vector2.h"
00005 #include "Interpolation.h"
00006 
00007 #include <cmath>
00008 
00009 namespace EdgeDetection
00010 {
00011         // Represents a two-dimensional edge by offset and angle
00012         class Edge
00013         {
00014                 private: double offset;
00015                 private: double angle;
00016 
00017                 public: double GetOffset() { return offset; }
00018                 public: double GetAngle() { return angle; }
00019                 public: Vector2 GetCenter() { return Vector2::Multiply(offset, Vector2(angle)); }
00020 
00021                 public: Edge()
00022                 {
00023                         this->offset = 0;
00024                         this->angle = 0;
00025                 }
00026                 public: Edge(double offset, double angle)
00027                 {
00028                         this->offset = offset;
00029                         this->angle = angle;
00030 
00031                         while (this->angle < -M_PI) this->angle += 2 * M_PI;
00032                         while (this->angle > +M_PI) this->angle -= 2 * M_PI;
00033                 }
00034                 public: ~Edge() { }
00035 
00036                 public: static double GetDistance(Edge edge1, Edge edge2)
00037                 {
00038                         while (edge1.angle - edge2.angle < -M_PI) edge1.angle += 2 * M_PI;
00039                         while (edge1.angle - edge2.angle > +M_PI) edge1.angle -= 2 * M_PI;
00040 
00041                         double offsetDifference = edge1.offset - edge2.offset;
00042                         double angleDifference = edge1.angle - edge2.angle;
00043         
00044                         return Vector2(offsetDifference, angleDifference).GetLength();
00045                 }
00046                 public: static Edge Interpolate(Edge edge1, Edge edge2, double fraction)
00047                 {
00048                         while (edge1.angle - edge2.angle < -M_PI) edge1.angle += 2 * M_PI;
00049                         while (edge1.angle - edge2.angle > +M_PI) edge1.angle -= 2 * M_PI;
00050 
00051                         double offset = Interpolation::InterpolateForward(edge1.offset, edge2.offset, fraction);
00052                         double angle = Interpolation::InterpolateForward(edge1.angle, edge2.angle, fraction);
00053 
00054                         return Edge(offset, angle);
00055                 }
00056         };
00057 };
00058 
00059 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


aruco_pose
Author(s): Julian Brunner
autogenerated on Thu May 23 2013 12:15:46