5 利用函数polarToCart(magnitude,angle[,x[,y[,angleInDegrees]]])实现极坐标转笛卡尔坐标
- 这样得到的笛卡尔坐标是以(0,0)为中心变换的
#include<opencv2/core/core.hpp>
#include<math.h>
#include<iostream>
#define PI acos(-1)
using namespace cv;
using namespace std;
int main()
{
Mat theta = (Mat_<float>(2, 2) << 30, 31, 30, 31);
Mat r = (Mat_<float>(2, 2) << 10, 10, 11, 11);
Mat x, y;
polarToCart(r, theta, x, y, true);
//以(0,0)为中心变换的
cout << x << endl;
cout << y << endl;
//以(-12,15)为中心变换的
x += -12;
y += 15;
cout << x << endl;
cout << y << endl;
return 0;
}