#include <iostream>
#include <fstream>
#include <string>
using namespace std;
string str(double x){
    return to_string(x);
};
struct R2{
    double x;
    double y;
    R2(double x_, double y_){
        x = x_; y = y_;
    }
    R2(){x = 0; y = 0;}
};
R2 operator+(R2 a, R2 b){
    R2 r;
    r.x = a.x + b.x;
    r.y = a.y + b.y;
    return r;
}
struct SVGGraph{
    double vx0, vy0, H, W;
    double r;
  	string s;
    SVGGraph(){
        vx0 = -1.2; vy0 = -1.2; W= 2.4; H= 2.4; r=0.1;
        s = "";

    }
    void setPointSize(double r_){
        r = r_;
    }
	void circle(R2 p){
        s += "<circle r='" + str(r) + "' cx='" +str(p.x) + "' cy='"+str(p.y) + "' fill='black' />\n";	
	}
    void drawVAxis(string title){
        s += "<text style='font-size:0.05;'  transform='translate(-1.1, 0) rotate(-90)'>"+title + "</text>";
        s += "<line x1='-1' y1='1' x2='-1' y2='-1' style='stroke:rgb(0,0,0);stroke-width:0.01' />";
    }
    void drawHAxis(string title){
        s += "<text style='font-size:0.05;'  transform='translate(0, 1.1) rotate(0)'>"+title + "</text>";
        s += "<line x1='-1' y1='1' x2='1' y2='1' style='stroke:rgb(0,0,0);stroke-width:0.01' />";
    }

	string serialize(){
        string r = "<svg xmlns='http://www.w3.org/2000/svg' viewBox='"+to_string(vx0)+" " + to_string(vy0) + " " + to_string(W) + " " + to_string(H) + "'>\n";
        r = r + s + "</svg>\n";
        return r;
	}
};
int main(){
	SVGGraph o;
    o.setPointSize(0.01);
    int N = 128+1;
    double h = 2*3.1415/N;
    double x=0.5;
    double y=0;

    for(int i=0;i<N;++i){
        x = x - y*h; y = y + x*h;
    	o.circle(R2(x, y));
    }
    o.drawVAxis("vertical axis");
    o.drawHAxis("horizontal axis");
	ofstream of("testGraphA.svg");
	of << o.serialize();
	return 0;
}
