#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

#define T_PI 3.14159265358979				//pi
#define D_PI 6.28318530717958647692			//2*pi

int main(int argc, char **argv)
{
	int i, j, k, B;
	double x, y, z, *theta, phi, int_t;
	
	FILE *f_coord;
	
	if (argc != 3)
	{
		printf("Usage : ./equiang B fichier\n");
		exit(1);
	}
	
	B = atoi(argv[1]);
	f_coord = fopen(argv[2],"w");
	theta = (double *)calloc(2*B*2*B, sizeof(double));
	
	fprintf(f_coord, "%d\n", 1);
	fprintf(f_coord, "%d\n", 2*B);
	
	for (i=0; i<2*B; i++)
	{
		int_t = T_PI*(2*i+1)/(4*B);
		for (j=0; j<2*B; j++)
		{
			k = i*2*B+j;
			theta[k] = int_t;
			phi = D_PI*j/(2*B);
			x = sin(int_t)*cos(phi);
			y = sin(int_t)*sin(phi);
			z = cos(int_t);
			fprintf(f_coord, "%f %f %f\n", x, y, z);
		}
	}
	for (i=0; i<(2*B*2*B); i++)
		fprintf(f_coord, "%f\n", theta[i]);
	
	fclose(f_coord);
	free(theta);
	
	return 0;
}
