#include <iostream>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
//Make Radius document -> ttp://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1215054992

/*double R(double L, double Degree){
	return L / (M_PI*(Degree / 180));
}
*/
double R(double L, int N){//組み込んだ
	double T = tan((M_PI/N));
	return (L / 2)*sqrt(1 + 1 / (T*T));
}

template<class T>
struct Vector2
{
	T x, y;
};
typedef Vector2<double> Vector2D;

template<class T>
Vector2<T> TransForm(Vector2<T>& Length, double RotRadian, Vector2<T>& Scale, Vector2<T>& Move)
{
	Vector2<T> Ret = { 0, };
	double Sin = sin(RotRadian);
	double Cos = cos(RotRadian);

	Ret.x = ((Length.x * Scale.x) * Cos) - ((Length.y * Scale.y) * Sin) + Move.x;
	Ret.y = ((Length.x * Scale.x) * Sin) + ((Length.y * Scale.y) * Cos) + Move.y;

	return Ret;
}

std::vector<Vector2D> SeiNKakukei(int N,double Rotaion, Vector2D Scale, Vector2D Move){
	double Degree = 360.0 / N;
	double Radius = R(1.0, N);
	std::vector<Vector2D> vec;
	Vector2D L{ Radius, 0 };


	for (int i = 0; i < N; i++){
		vec.push_back(TransForm(L, ((Degree*i)+Rotaion - 90)*(M_PI / 180.0), Scale, Move));
	}
	return vec;
}

int main(){
	double Rot = 0;
	Vector2D S{ 1, 1 };
	Vector2D M{ 0, 0 };

	for (int N = 3; N < 9; N++){
		auto vec = SeiNKakukei(N, Rot, S, M);
		std::cout << "正" << N << "角形？？：";
		for (auto& o : vec)	std::cout << '[' << o.x << ',' << o.y << ']' << ',';
		std::cout << std::endl;
	}
	int N = 3;
	for (int R = 0; R < 360; R+=45){
		auto vec = SeiNKakukei(N, R, S, M);
		std::cout << "正" << N << "角形？？：";
		for (auto& o : vec)	std::cout << '[' << o.x << ',' << o.y << ']' << ',';
		std::cout << std::endl;
	}
	return 0;
}