Пример #1
0
int lh_iso(lua_State *L) {
  checkArg(L, 2, "isoproject");
  IsoParam *P = luaO(2, IsoParam);
  
  int t0;
  int ti = luaInt(1);
  t0 = addFreeform(distill(ti, spIFloor), P->Floor);
  t0 = addMerge(t0, addFreeform(addRecolor(distill(ti, spIWallL), 0xFF808080, recMult), P->WalL), false);
  t0 = addMerge(t0, addFreeform(addRecolor(distill(ti, spIWallR), 0xFFC0C0C0, recMult), P->WalR), false);
//t0 = addMerge(t0, addFreeform(distill(ti, spIWallL), P->WalL), false);
//t0 = addMerge(t0, addFreeform(distill(ti, spIWallR), P->WalR), false);
  t0 = addMerge(t0, addFreeform(distill(ti, spICeil), P->Ceil), false);
  t0 = addMerge(t0, addFreeform(distill(ti, spIItem), P->Item), false);
  
  return retInt(L, t0);
  // return retInt(L, renderAsIso(luaInt(1), spIFloor | spIItem | spIWallL | spIWallR | spICeil, luaO(2, IsoParam)));
  }
Пример #2
0
static void
_distill(void)
{
	p2 = pop();
	p1 = pop();

	// is the entire expression constant?

	if (find(p1, p2) == 0) {
		push(p1);
		//push(p1);	// may need later for pushing both +a, -a
		//negate();
		return;
	}

	// sum?

	if (isadd(p1)) {
		distill_sum();
		return;
	}

	// product?

	if (car(p1) == symbol(MULTIPLY)) {
		distill_product();
		return;
	}

	// naive distill if not sum or product

	p3 = cdr(p1);
	while (iscons(p3)) {
		push(car(p3));
		push(p2);
		distill();
		p3 = cdr(p3);
	}
}
Пример #3
0
void
distill_product(void)
{
	int h;

	// distill factors involving x

	p3 = cdr(p1);

	while (iscons(p3)) {
		if (find(car(p3), p2)) {
			push(car(p3));
			push(p2);
			distill();
		}
		p3 = cdr(p3);
	}

	// multiply together all constant factors

	h = tos;

	p3 = cdr(p1);

	while (iscons(p3)) {
		if (find(car(p3), p2) == 0)
			push(car(p3));
		p3 = cdr(p3);
	}

	if (tos - h) {
		multiply_all(tos - h);
		//p3 = pop();	// may need later for pushing both +a, -a
		//push(p3);
		//push(p3);
		//negate();
	}
}
Пример #4
0
void
distill_sum(void)
{
	int h;

	// distill terms involving x

	p3 = cdr(p1);

	while (iscons(p3)) {
		if (find(car(p3), p2)) {
			push(car(p3));
			push(p2);
			distill();
		}
		p3 = cdr(p3);
	}

	// add together all constant terms

	h = tos;

	p3 = cdr(p1);

	while (iscons(p3)) {
		if (find(car(p3), p2) == 0)
			push(car(p3));
		p3 = cdr(p3);
	}

	if (tos - h) {
		add_all(tos - h);
		p3 = pop();
		push(p3);
		push(p3);
		negate();	// need both +a, -a for some integrals
	}
}