Question

My application obtains x,y,z coordinates like this:

x: -0.020941
y: -0.241276
z: 0.956
--------------
x: 0.0782352
y: -0.159108
z: 0.923
--------------
x: 0.0665857
y: -0.140757
z: 0.885
--------------
x: 0.0485952
y: -0.0859762
z: 0.785
--------------
x: 0.04494
y: -0.0477933
z: 0.749
--------------
x: -0.183467
y: 0.0505905
z: 0.64
--------------
x: -0.0519514
y: -0.0137343
z: 0.627
--------------
x: -0.0630648
y: -0.0206495
z: 0.586
--------------
x: -0.0774924
y: -0.0189667
z: 0.569
--------------
x: 0.0100971
y: -0.0100971
z: 0.558
--------------
x: 0.00456857
y: -0.0126905
z: 0.533
--------------
x: 0.000491429
y: -0.00835429
z: 0.516
--------------
x: -0.0227838
y: -0.01018
z: 0.509
--------------
x: -0.0222133
y: -0.00589333
z: 0.476
--------------
x: -0.10161
y: -0.00850476
z: 0.47
--------------
x: -0.0775429
y: 0.0162095
z: 0.46
--------------
x: -0.0897705
y: 0.0219057
z: 0.451
--------------

What I'm doing is every 3 seconds I'm taking the smallest z value from this stream and plotting it's position within a 2d array (using it's x and y position)

my question is how do I plot this result as I don't know what the maximum or minimum score could be and they're all double type, not int for the index. Is there a 'nice' way of plotting this? I'd also like to be able to manipulate this data based on it's array index. e.g. find where data is clustering, etc.

Was it helpful?

Solution

It seems that your issue is a result of having your heart set on using an array. Using a vector would allow you to add grid points dynamically as well as averaging (and performing other calculations) whenever you wanted.

That being said, if you really want to use an array then like you have noticed you cannot use doubles and/or negative values as indices. You could work out a system by adding an offset and multiplying your x,y values to get rounded integers and a center not at (0,0) but maybe at (2,2) or something instead but this would be really unwieldy and confusing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top