Created
November 18, 2015 09:37
-
-
Save RDCH106/46702f81783cce971c1a to your computer and use it in GitHub Desktop.
Calculate the similar polygon that it is concentric to the original polygon, using a scaling factor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "opencv2/opencv.hpp" | |
#include <vector> | |
using namespace cv; | |
using namespace std; | |
vector<Point> calculateSimilarPolygon(vector<Point>&pListPoints, Point center, float factor){ | |
vector<Point> spolygon; | |
float v1, v2; | |
int x, y; | |
for(int i=0; i<pListPoints.size(); i++){ | |
//Initialization | |
x=0; y=0; | |
v1=0; v2=0; | |
v1 = pListPoints.at(i).x - center.x; | |
v2 = pListPoints.at(i).y - center.y; | |
x = center.x + v1*factor; | |
y = center.y + v2*factor; | |
spolygon.push_back(Point(x,y)); | |
} | |
return spolygon; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment