Just adding that this works best if the radius and coordinates of the centre of the square are integers and big enough that the algorithm can do +1 and -1 increments to find the points. That is determined by the way you calculate the tempX and tempY matrices. Perhaps there could be an input to select how many points you want per side and then create the tempX and tempY matrices accordingly. Might make it... Thanks!