tags:

views:

52

answers:

1

Given p(0,0), how do I retrieve points{(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1)} which are the perimeter points relative to p offset by 1.

+1  A: 
for(x = p.x -1; x <= p.x + 1; x++) {
    for(y = p.y -1; y <= p.y + 1; y++) {
        // Do some stuff with each p
    }
}

Generic code here. Alter for your programming language and how you store the points.

Macha
i'll test you code first
ken