Beispiel #1
0
void drawArc(Point2 centre, float radius, float startAngle, float sweep)
{
	Turtle t;
	const int n = 30;
	float angle = startAngle * M_PI / 180;
	float angleInc = sweep * M_PI / (180 * n);
	float cx = centre.getX(), cy = centre.getY();
	t.moveTo(Point2(cx + radius*cos(angle), cy + radius*sin(angle)));
	for (int k = 1; k < n; k++, angle += angleInc)
	{
		t.lineTo(Point2(cx + radius*cos(angle), cy + radius*sin(angle)));
	}
}
Beispiel #2
0
void drawArc(Point centre, float radius, float startAngle, float sweep)
{
	Turtle t;
	const int n = 30;
	float angle = startAngle * M_PI / 180; //convert to radian
	float angleInc = sweep * M_PI / (180 * n);
	float cx = centre.getX(), cy = centre.getY();	//200,200
	float a, b;
	a = cx + radius*cos(angle);
	b = cy + radius*sin(angle);
	t.moveTo(Point(a, b));
	for (int k = 1; k < n; k++, angle += angleInc)
	{
		t.lineTo(Point(cx + radius*cos(angle), cy + radius*sin(angle)));
	}
}