阿基米德螺旋線繪制


關於極坐標與直角坐標:極坐標方程與直角坐標方程的互化

參考:阿基米德螺旋線

手把手教你用C++畫木葉標志

#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;
}

結果圖:

                                                                 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM