Can you tell us exactly what doesnt work. Its generally very useful to give a statement like, "I expect ..., but what I'm getting is ...".
running the code, I get teh pretty clear error, "Undefined function or variable points." You are trying to concatinate the variable points before it exists. You need to define points before your loops.
points = [];
I suspect there are more issues but we'll need more information before I can help further.