Function:s2funxz
From S2PLOT
(Difference between revisions)
Current revision
s2funxz
Draw the surface described by the provided function fxz.
Prototype
void s2funxz(float(*fxz)(float*,float*), int nx, int nz, float xmin, float xmax, float zmin, float zmax, int ctl);
Description
Draw the surface described by the function fxz. The function is evaluated on a nx * nz grid whose world coordinates extend from (xmin,zmin) to (xmax,zmax). The ctl argument has the following effect:
- ctl = 0: curve plotted in current window and viewport. Caller is responsible for setting the viewport and world coordinate system suitably.
- ctl = 1: s2env is called automatically to fit the plot in the current viewport.
Beware that these functions consume memory to store all the function evaluations prior to triangulating the surface.
See Also
s2funxy | Draw the surface described by the provided function fxy. |
s2funyz | Draw the surface described by the provided function fyz. |
s2funxzr | Draw surface as per s2funxz, but with explicit settings for the colour range mapping. |
s2env | Convenience function which sets the plotting environment. |
PGPLOT Equivalent
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "s2plot.h"
#define XLIMIT 1.0
#define YLIMIT 1.0
#define ZLIMIT 1.0
float fxy(float *x, float *y)
{
return ((*x)*(*x) + 0.25*(*y)*(*y)); /* Function to evaluate */
}
float fxz(float *x, float *z)
{
return (0.1*(*x)*(*x) + 0.1*(*z)*(*z)); /* Function to evaluate */
}
float fyz(float *y, float *z)
{
return (-0.3*(*y)*(*y) - 0.3*(*z)*(*z)); /* Function to evaluate */
}
int main(int argc, char *argv[])
{
int nx = 64, ny = 64, nz = 64;
/* Resolution of grids to plot function on */
int ctl = 0; /* User responsible for setting environ */
float x1 = -XLIMIT*1.5, x2 = +XLIMIT*1.5; /* World coordinates */
float y1 = -YLIMIT*1.5, y2 = +YLIMIT*1.5;
float z1 = -ZLIMIT*1.5, z2 = +ZLIMIT*1.5;
s2opend("/?",argc,argv); /* Open the display */
s2swin(x1,x2,y1,y2,z1,z2); /* Set the window coordinates */
s2box("BCDET",0,0,"BCDET",0,0,"BCDET",0,0); /* Draw coordinate box */
s2icm("rainbow",1000,2000);
s2scir(1000,2000);
s2funxy(fxy, nx, ny, -XLIMIT,XLIMIT, -YLIMIT,YLIMIT, ctl);
/* Functional surface in X-Y plane */
s2icm("astro",2000,3000);
s2scir(2000,3000);
s2funxz(fxz, nx, nz, -XLIMIT,XLIMIT, -ZLIMIT,ZLIMIT, ctl);
/* Functional surface in X-Z plane */
s2icm("mgreen",3000,4000);
s2scir(3000,4000);
s2funyz(fyz, ny, nz, -YLIMIT,YLIMIT, -ZLIMIT,ZLIMIT, ctl);
/* Functional surface in Y-Y plane */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.