Index: work/sbiarc/main.c =================================================================== --- work/sbiarc/main.c (revision 37159) +++ work/sbiarc/main.c (revision 37160) @@ -1,12 +1,62 @@ +#include +#include #include "sbiarc.h" +static void draw_begin(void) +{ +printf("\n"); +printf("\n"); + +/*width="2032.0000" height="2032.0000" viewBox="-2.0000 -2.0000 132.0000 132.0000"*/ +} + +static void draw_end(void) +{ + printf("\n"); +} + +static void draw_line(double x1, double y1, double x2, double y2) +{ + printf(" \n", x1, y1, x2, y2); +} + +static void draw_sba(sba_t *s) +{ + double a, astep, r, rstep, steps; + + printf(" \n", s->cx[0], s->cy[0], s->r[0]); + printf(" \n", s->cx[1], s->cy[1], s->r[1]); + + + astep = (s->start < s->ipa[0]) ? 0.1 : -0.1; + + steps = (s->ipa[0] - s->start) / astep; + rstep = ((s->r[0] + s->r[1]) / 2 - s->r[0]) / steps; +fprintf(stderr, "astep=%f start=%f ipa=%f rstep=%f (steps=%f)\n", astep, s->start, s->ipa[0], rstep, steps); + for(a = s->start, r = s->r[0]; astep > 0 ? (a < s->ipa[0]) : (a > s->ipa[0]); a += astep, r += rstep) { + double x, y; + x = s->cx[0] + cos(a) * r; + y = s->cy[0] + sin(a) * r; + draw_line(s->cx[0], s->cy[0], x, y); + if (a > 2*M_PI) + a -= 2*M_PI; + if (a < -2*M_PI) + a += 2*M_PI; +fprintf(stderr, "a=%f\n", a); + } +} + int main() { sba_t s; s.cx[0] = 10; s.cy[0] = 1; s.r[0] = 5; s.cx[1] = 40; s.cy[1] = 5; s.r[1] = 9; - s.style = SBA_STRAIGHT; + s.start = M_PI/2; s.delta = -M_PI * 2; + s.style = SBA_INFLEX; sba_update(&s); + draw_begin(); + draw_sba(&s); + draw_end(); }