X-Git-Url: http://git.maemo.org/git/?p=scdataviz;a=blobdiff_plain;f=graph.c;h=423ff84a121674d30d1f7cb60604b278b0b458df;hp=1b0f4685303145fd16d756b21f1202184e63917c;hb=2329e96577a27c47e5287118d8808542fbed12ec;hpb=0c8587ee853fe75d965f89a9de1901166c544001 diff --git a/graph.c b/graph.c index 1b0f468..423ff84 100644 --- a/graph.c +++ b/graph.c @@ -125,10 +125,10 @@ static void linear_interpolate(gpointer data, gpointer user_data) { struct cxt *cxt = user_data; struct graph_point *p3 = data; if(cxt->p0 != NULL) { - double p1_x = (p3->x - cxt->p0->x)/3.0; - double p1_y = (p3->y - cxt->p0->y)/3.0; - double p2_x = (p3->x + 2*cxt->p0->x)/3.0; - double p2_y = (p3->y + 2*cxt->p0->y)/3.0; + double p1_x = (p3->x + 2*cxt->p0->x)/3.0; + double p1_y = (p3->y + 2*cxt->p0->y)/3.0; + double p2_x = (2*p3->x + cxt->p0->x)/3.0; + double p2_y = (2*p3->y + cxt->p0->y)/3.0; graph_add_line(cxt->graph, cxt->p0->x, cxt->p0->y, p1_x, p1_y, p2_x, p2_y, p3->x, p3->y); } cxt->p0 = p3; @@ -140,3 +140,13 @@ void graph_add_linear_connectors(Graph* graph) { cxt.p0 = NULL; g_ptr_array_foreach(graph->points, &linear_interpolate, &cxt); } + +void graph_bezier_linear_to_cubic(double x0, double x3, double *x1, double *x2) { + *x1 = (x3 + 2.0*x0)/3.0; + *x2 = (2.0*x3 + x0)/3.0; +} + +void graph_bezier_qudratic_to_cubic(double x0, double x3, double *x1, double *x2) { + *x2 = (x3 - x0)/3.0 + (*x1); + *x1 = (x0 - 3.0*(*x1))/2.0; +}