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.
views:
52answers:
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
2009-04-01 11:41:51
i'll test you code first
ken
2009-04-01 12:04:29