10-30-2009 03:59 PM
Hi all,
I need to write a VI with the following specifications:
Input: An integer
Output: Two integers mapping the input integer to a coordinate system based on the following mapping system:
22 23 24 25 ..
21 06 07 08 09
20 05 00 01 10
19 04 03 02 11
18 44 45 46 12
17 16 15 14 13
For instance, an input of 0 would be an output of (0,0). An input of 5 would be an output of (-1, 0) and an input of 23 would be an output of (-1, 2).
As you can see it is just a clockwise rectangular coordinate system starting with 0 in the middle.
I am new to LabVIEW and am having trouble visualizing how to do this. If I were in a text based language, I would do something like create a 2d array of booleans representing my coordinate system, and travel around in a clockwise circle marking each as true until I reached the input number, then output my current row and column. Does anyone have any suggestions of the best way to do it in LabVIEW? (In case you were curious why I don't stick with a language I know-- LabVIEW has the drivers for the motion controller I am using).
I know this is not as complex as many of the questions here, but any help or tips would be appreciated!
10-30-2009 04:31 PM
Here is one way to do it. The constants in the loop represent the offset of your starting point, in this case the 0 value at 2,2.
10-30-2009 07:18 PM
22 23 24 25 ..
21 06 07 08 09
20 05 00 01 10
19 04 03 02 11
18 44 45 46 12
17 16 15 14 13
As you can see it is just a clockwise rectangular coordinate system starting with 0 in the middle.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
10-30-2009 07:28 PM
Of course, I don't know what you are doing with this, but I would point out that whether you are generating the table, or just doing the lookup - the "30" constant, the "5x5" array initializer, and the "2+2i" starting point should all be related: computed from something common, not independent constants as I showed them.
More fun: attach an intensity graph to the generated array:
Blog for (mostly LabVIEW) programmers: Tips And Tricks