Skip to content

Instantly share code, notes, and snippets.

@RDCH106
Created November 18, 2015 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RDCH106/46702f81783cce971c1a to your computer and use it in GitHub Desktop.
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
#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