Drawing api

i’m suppose to create a drawing api which consist of a line tool and a closed polygon tool. users are able to use this line tools to draw straight line between any 2 point. and the polygon tool is to create a shape irregardless of how many points as long as the first dot and the last dot meets, it will form a shape. is there a way to find the angles inside the polygon? is there also a way to find the point where the lines intersect and its angles?