# To subscribers of the xforms list from spl@donor.ucsd.edu :
> I've been able to change your source code that you supplied to reflect what
> was happening on my end. I also found the reason why it happened and have
> corrected it in my program. See if you can tell what I did wrong.
> [...]
> int idle( XEvent *xev, void *data )
>
> {
>
> static int i = 0;
> static int nocnt;
> double x = ( i * M_PI ) / N;
> double y1 = sin( x );
> double y2 = cos( x );
>
> fl_insert_xyplot_data( try1->xyplot, 1, nocnt, x, y1 );
> fl_insert_xyplot_data( try2->xyplot, 1, i, x, y2 );
>
> i++;
>
> return i;
>
> }
Well, the variable `nocnt' is never initialized or updated. By
definition (he says, digging out the copy of Kernighan and Ritchie
from the bottom of a large pile of books and manuals teetering on the
edge of the desk and putting on the rather tattered "Language Lawyer"
hat -- the one with all the bullet holes in it -- kept hidden in the
bottom drawer along with the empty bottles of Tylenol), `static's are
initialized to zero, so this is always zero.
> My next question is:
>
> Is this an undocumented feature? Or is this something that I just happened
> to come across? 8-)
It is documented.
According to the manual, `n' (the third argument of the
fl_insert_xyplot_data() function is the point *after* which the new
point will be added. The first pass through, there are no points so
for want of anything else to do, the first point is put into array
index 0, so we have
index X Y
0 0 0
Second pass through, we add a point *after* point 0, giving
0 0 0
1 0.15708 0.156434
Now with pass 3 the fun begins.
0 0 0
1 0.314159 0.309017
2 0.15708 0.156434
Point 1 is shoved out of the way (into array index 2).
After pass 10 we have
0 0 0
1 1.41372 0.987688
2 1.25664 0.951057
3 1.09956 0.891007
4 0.942478 0.809017
5 0.785398 0.707107
6 0.628319 0.587785
7 0.471239 0.45399
8 0.314159 0.309017
9 0.15708 0.156434
Not exactly what you wanted but correct behavior from XYplot's
standpoint.
spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/
This archive was generated by hypermail 2b29 : Fri Sep 29 2000 - 13:41:43 EDT