Ejemplo n.º 1
0
void main() {
	term a, b, sum;
	printf(" Enter 1st polynomial in form <coeff deg>: \n");
	polyRead(&a);
	printf("\n Enter 2nd polynomial in form <coeff deg>: \n");
	polyRead(&b);
	
	polyAdd(&a, &b, &sum);
	
	printf("\n");
	polyDisplay(&a);
	printf("  +  ");
	polyDisplay(&b);
	printf("\n = ");
	polyDisplay(&sum);
	printf("\n\n");
	
	polyFree(&a);
	polyFree(&b);
	polyFree(&sum);
}
Ejemplo n.º 2
0
 /* freeNodes:
  * Free node resources.
  */
static void freeNodes(void)
{
    int i;
    Info_t *ip = nodeInfo;

    for (i = 0; i < nsites; i++) {
	breakPoly(&ip->poly);
	ip++;
    }
    polyFree();
    infoinit();			/* Free vertices */
    free(nodeInfo);
}
Ejemplo n.º 3
0
static int
putface(				/* put out an N-sided polygon */
	int	ac,
	char	**av
)
{
	Vert2_list	*poly = polyAlloc(ac);
	int		i, ax, ay;

	if (poly == NULL)
		return(0);
	poly->p = (void *)av;
	for (i = ac-3; i >= 0; i--)	/* identify dominant axis */
		if ((ax = dominant_axis(av[i], av[i+1], av[i+2])) >= 0)
			break;
	if (ax < 0)
		return(1);		/* ignore degenerate face */
	if (++ax >= 3) ax = 0;
	ay = ax;
	if (++ay >= 3) ay = 0;
	for (i = 0; i < ac; i++) {	/* convert to 2-D polygon */
		VNDX	vi;
		if (!cvtndx(vi, av[i])) {
			error(WARNING, "bad vertex reference");
			polyFree(poly);
			return(0);
		}
		poly->v[i].mX = vlist[vi[0]][ax];
		poly->v[i].mY = vlist[vi[0]][ay];
	}
					/* break into triangles & output */
	if (!polyTriangulate(poly, &tri_out)) {
		sprintf(errmsg, "self-intersecting face with %d vertices", ac);
		error(WARNING, errmsg);
	}
	polyFree(poly);
	return(1);
}