|
Find xy coordinates of X element in array |
Manimecker
Member #15,031
April 2013
|
Hello!! I hope you guys are having such a good day. Maybe this is a dumb question, but I still don't get it. Let's say I create a 4x4 array. Which I filled with some increasing numbers... like this: 1... 2... 3... 4... What I need to do is: given the number of the element (1...16) find the xy coordinates of such element. Like this: Let's say I want to find the xy coordinates of the 11 element. No idea how to do it. However, I know how to find the element number given the xy coordinates: Like if I want to find the element number given the X=4, Y=2 coordinates. X=2, Y=3 I just don't know how to do the inverse function, finding xy coordinates given the element number... Maybe it's too easy, but I jut can't find it out. Thanks in advance guys! |
ph03nix
Member #15,028
April 2013
|
EDIT: stupid me, I didn't read the question at all. You want to get the x and y coordinates from a position in the index, which is a bit different. Here's how you do that: y = ind/cols "ind" is the index of the array you are converting to xy coordinates. EDIT: remember that y, x, and the array index should start from 0, not 1 |
Manimecker
Member #15,031
April 2013
|
You were right!! Thank you so, so much! |
|