LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Using 3dGraphCtrl

Hi I am having trouble using the 3dGrapgh Contol in labwindows.
I am trying to display
zernike codes which are just mathematical functions. There is an image attached showing these.
Imagine these as a circle that has been distorted by a function.

I can get these to equation to display but only if the surface is rectangular, ie for
all x and y values in the array of z's.

I am using  
CW3DGraphLib_CWPlot3DPlot3DSurface
to display these.

How do I display a surface of z values for a circular pattern of x and y's ?
for example an oval twisted 45 degress.
The image shows what I mean better.
Hope I explained this well enough.
Thanks
Glenn
0 Kudos
Message 1 of 4
(4,227 Views)

Hi,

  the x and y arrays (vectors) don't have to contain 1,2,3,4,5 etc. They can be setup as value pairs and then the 2D array for Z matches element by element to the elements in the x and y array.

i.e. to plot the Z array

1,2,3

4,5,6

at

x=0.1,0.2,0.6,0.9,

y=0.7,-1.2,3.4,-9.6

would then plot the z array value1 (element 1,1) at position 0.1,0.7 (x,y) etc

I think this is where the issue is coming in - if I read what you're trying to do correctly you're treating the 3D graph as a square sheet, and you don't want the "corners" showing on the data.

Is that it?

If you've snapped out the x,y to a circular subsection then you'll need to cut that section from your data before passing it to the Plot3DSurface function.

Hope that helps.

Sacha Emery
National Instruments (UK)

// it takes almost no time to rate an answer Smiley Wink
Message 2 of 4
(4,190 Views)

That is what I am trying todo but I am still having problems.

I have attached a test project.

I believe my xdata and ydata arrays are setup correctly now.

In the test project I am trying to display a flat circle at a value of 1 on the z axis.

I believe the problem may be the z value array not being the correct size ?

Any help greatly appreciated.

 

Thanks

0 Kudos
Message 3 of 4
(4,150 Views)

Hi,

  I've just realised - the setup you're using is a surface graph - you need the parametric setup instead to miss out the corners (you can still plot a surface on that, it's just each array row then represents a data set of joined points so you can describe a circle at a particular radius Two rows then equate to a surface since you have two sets of data.

You pass in 3 x 2D arrays to define the surface to avoid the corners that you get with a normal surface plot.

In your case, the x, y and z matrices will be all the same size. The z matrix would be all '1's since you said you want to plot a flat circle.

so you x and y's would make a surface using sin and cosine similar to :

 radius = 5.0;
 
 for (x = 0;x<2;x++)
  for (y=0;y<360;y++)
  {
   xData[x][y] = sin(((double)y*PI)/180)*(double)x * radius;
   yData[x][y] = cos(((double)y*PI)/180)*(double)x * radius;
   zData[x][y] = 1.0;
  }

this would generate a central point (referencing 0,0,1 multiple times, and then a outer circle at a particular radius so you get a surface)

Hope that makes sense.

Sacha Emery
National Instruments (UK)

Message Edited by SachaE on 08-29-2006 12:27 PM

// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 4 of 4
(4,093 Views)