关于极坐标与直角坐标:极坐标方程与直角坐标方程的互化
参考:阿基米德螺旋线
#include <iostream> #include<opencv2/opencv.hpp> #include "math.h" using namespace std; using namespace cv; #define pi 3.1415927 int main() { Mat background = Mat::zeros(600,600,CV_8U); float a=10, b = 10; int x = 0,y=0; double theta = 0; multimap<int,int> temp;//由于存在很多X值相同的点,所以这里用multimap while(theta<6*pi) { x = int((a+b*theta)*cos(theta)+300); y = int((a+b*theta)*sin(theta)+300); theta += 0.1; temp.insert(make_pair(x,y)); } for(auto inter = temp.begin();inter!=temp.end();inter++) { Point t(inter->first,inter->second); circle(background,t,2,Scalar(255,0,0),-1); } imshow("bg",background); imwrite("E:/1.png",background); waitKey(0); return 0; }
结果图: