Hi, your 'isNan' function is missing.
this does the job

#define isnan(x) ((x) != (x))

ps. The position sometimes works but most of the time is way off and jittering. I'm using 0, 0.5, 1 for the s1,s2,s3. Is that ok?- Vectrex