Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "mplot.h"
2
void parabola(double x0, double y0, double x1, double y1, double xb, double yb){
3
	register double x, y, t;
4
	double	c0x, c0y, c1x, c1y;
5
	double	dt, d2, d1;
6
	d1 = sqrt((xb - x0) * (xb - x0) + (yb - y0) * (yb - y0));
7
	d2 = sqrt((xb - x1) * (xb - x1) + (yb - y1) * (yb - y1));
8
	if (d1 <= e1->quantum || d2 <= e1->quantum) { 
9
		plotline(x0, y0, x1, y1); 
10
		return; 
11
	}
12
	c0x = x0 + x1 - 2. * xb; 
13
	c1x = 2. * (xb - x0);
14
	c0y = y0 + y1 - 2. * yb; 
15
	c1y = 2. * (yb - y0);
16
	move(x0, y0);
17
	dt = e1->quantum / d1;
18
	dt /= e1->grade;
19
	for (t = dt; t < 0.5; t += dt) {
20
		x = (c0x * t + c1x) * t + x0;
21
		y = (c0y * t + c1y) * t + y0;
22
		vec(x, y);
23
	}
24
	dt = e1->quantum / d2;
25
	dt /= e1->grade;
26
	for (; t < 1.0; t += dt) {
27
		x = (c0x * t + c1x) * t + x0;
28
		y = (c0y * t + c1y) * t + y0;
29
		vec(x, y);
30
	}
31
	vec(x1, y1);
32
}