Zwiebelchen
Hosted Project GR
- Joined
- Sep 17, 2009
- Messages
- 7,234
I got a simple maths problem I simply can not figure out, but I need it to complete a system I am writing atm.
I got two squares of equal edge size containing grid coordinates.
Both squares intersect each other. I need to get a simple formula to gather all grid coordinates that are in square A but not in square B and all coordinates that are in square B but not in square A.
See picture below:
Can someone give me the fastest enumeration algorythm that matches the XOR condition here? I need an algorythm that ONLY enums the coordinates that are needed and would like to avoid useless enumerations of the intersection coordinates!
Basicly, an algorythm that uses as few enumeration steps as possible!
I got two squares of equal edge size containing grid coordinates.
Both squares intersect each other. I need to get a simple formula to gather all grid coordinates that are in square A but not in square B and all coordinates that are in square B but not in square A.
See picture below:
Code:
example (edge size = 5):
o o o o o o o 7
o o x x x x x 6
* * / / / x x 5
* * / / @ x x 4
* * @ / / x x 3
* * / / / x x 2
* * * * * o o 1
o o o o o o o 0
0 1 2 3 4 5 6
@: center coords of squares
crosses and stars are to be enumerated.
Can someone give me the fastest enumeration algorythm that matches the XOR condition here? I need an algorythm that ONLY enums the coordinates that are needed and would like to avoid useless enumerations of the intersection coordinates!
Basicly, an algorythm that uses as few enumeration steps as possible!