LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

weighted slope of a 3x3 matrix

Ok, I have a somewhat unusual maths requirement (well unusual to me anyway).

Say I have a 3x3 matrix, each with a value (0...255).  Assuming this represents the surface of a physical object (and I know that the center box is not zero), I want to get the surface vector in order to be able to work with the "slope" of this surface.  Clear?

Example

0 0 0
2 2 2
2 2 2  Must give a normal of zero,


2 0 0
2 2 0
2 2 2 Should give normal of -1.

0 0 2
0 2 2
2 2 2 should give a normal of 1


And so on.  The hope is that through the weighting of the boxes (a larger number carries more weight in the calculation) I can simulate more than just 8 directions.

Also, the output (plus/minus and so on) is flexible, I simply must be able to correlate this to a surface normal (always pointing up).

I've tried placing artificial points on an XY plane in each of the 8 directions with the distance in the given direction defined by the respective number within the matrix.  This is half-satisfactory as it seems to bear SOME resemblance to a logical answer, but it's not quite there.

Can anyone help me?
Perhaps it's better if I ask if anyone can understand me?

Looking forward to any help

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 1 of 4
(2,963 Views)
OK, I think maybe just thinking about might have jolted some dark distant thoughts from way back....

If I simply get the mid-point of all the points I have artificially created and use this and 0,0 as two ends of a line, the slope of this line should be representative.... (?)

I'll try to get an example up.

Sometimes my lack of numerical prowess is really depressing 😞

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 4
(2,959 Views)
OK, just to finish up a silly thread.

I have it sorted, as long as the matrix isn't symmetrical, whereby I get a NaN.....

This is my current code (much of the code is for comparison purposes only).

If only I could think properly, I wouldn't be polluting the forum with this stuff,

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 3 of 4
(2,956 Views)
Shane,

This sounds like fun. I have a math handbook which has lots of stuff on 3D analytic geometry. To translate their nomenclature to LV code, I need to understand your "surface." Does the 3x3 matrix represent the Z-axis values at 0+/-1 on X and Y? If you can explicitly define the surface in 3D, I can generate the normal fairly easily (I think)>

Lynn
0 Kudos
Message 4 of 4
(2,953 Views)