aboutsummaryrefslogtreecommitdiffstats
path: root/rtgrpblib_draw_circular_arc.c
blob: f30fde7329585ad7ec9f8841d4498ec7fd2eebba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* See LICENSE file for copyright and license details. */
#include "common.h"
#ifndef TEST


void
rtgrpblib_draw_circular_arc(RASTER *restrict raster, double x0, double y0,
                            double semiwidth, double semiheight, double start, double end)
{
	double inc, v, x, y, prevX, prevY;

	if (start == end)
		return;

	/* TODO precalculate intersection with raster box */

	inc = fmax(semiwidth, semiheight);
	inc *= 2 * M_PI;
	inc *= end - start;
	inc = raster->draftness / inc;

	v = start;
	prevX = x0 + semiwidth * cos(start);
	prevY = y0 + semiheight * sin(start);

	for (; (v += inc) < end; prevX = x, prevY = y) {
		x = x0 + semiwidth * cos(v);
		y = y0 + semiheight * sin(v);
		rtgrpblib_draw_linear_bezier(raster, prevX, prevY, x, y);
	}

	x = x0 + semiwidth * cos(end);
	y = y0 + semiheight * sin(end);
	rtgrpblib_draw_linear_bezier(raster, prevX, prevY, x, y);
}


#else


int
main(void)
{
	return 0; /* TODO add test */
}


#endif