Function:s2funt
From S2PLOT
s2funt
Draw a curve defined by parametric equations fx(t), fy(t) and fz(t).
Prototype
void s2funt(float(*fx)(float*), float(*fy)(float*), float(*fz)(float*), int N, float tmin, float tmax);
Description
Draw a curve defined by parametric equations fx(t), fy(t) and fz(t). N points are constructed, uniformly spaced from tmin to tmax.
See Also
s2funtc | Draw a curve defined by parametric equations fx(t), fy(t) and fz(t) with colour control. |
PGPLOT Equivalent
Code Example
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "s2plot.h"
#define XLIMIT 10.0
#define YLIMIT 10.0
#define ZLIMIT 50.0
#define TWOPI 6.2831853
float fx(float *t)
{
return XLIMIT * sin(*t);
}
inline float fy(float *t)
{
return YLIMIT * *t / TWOPI * cos(*t);
}
float fz(float *t)
{
return 20. + (ZLIMIT * *t / TWOPI + 4.*sin(5* *t)*sin(3* *t))*0.5;
}
int main(int argc, char *argv[])
{
float x1 = -XLIMIT, x2 = XLIMIT; /* x world coord range */
float y1 = -YLIMIT, y2 = YLIMIT; /* y world coord range */
float z1 = -ZLIMIT/4.0, z2 = ZLIMIT; /* z world coord range */
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 */
s2sci(S2_PG_YELLOW);
s2slw(3); /* Set the line width */
s2funt(&fx, &fy, &fz, 1000, -TWOPI, TWOPI); /* Draw parametric line */
s2show(1); /* Open the s2plot window */
return 1;
}
Back to S2PLOT function list.