#!/usr/bin/env python

#Star coordinate calculation
#foolswood.co.uk 2012

from math import sin, cos, pi

def getStarPts(npts, r1, r2, angle=pi/2):
	'''Get the coordinates of the outline of a star
	
	npts is the number of points on the star
	r1 and r2 are the inner and outer spoke radii
	angle is the offset of the first point from the +x axis'''
	angle_step = pi/npts
	pts = []
	for n in range(npts*2):
		if (n%2):
			r = r1
		else:
			r = r2
		pts.append((r*cos(angle), r*sin(angle)))
		angle += angle_step
	return pts

def svgPolyfy(pts):
	'''Convert a set of points to the point format of an svg polygon
	
	Expressed to 1 decimal place of precision'''
	ptstr = ""
	for pt in pts:
		ptstr += '{0[0]:.1f},{0[1]:.1f} '.format(pt)
	return ptstr.strip().replace(".0", "").replace("-0", "0")

print svgPolyfy(getStarPts(5, 60, 30))
