示例#1
0
void SampleModel::drawLeftHandJoint() {
	glPushMatrix();
	glTranslated(-UPPER_TORSO_RADIUS, 0.6, 0);
	glRotated(20, 0.0, 0.0, -1.0);
	glRotated(90, 0.0, 1.0, 0.0);
	glTranslated(0, 0, -0.2);
	if (VAL(TEXTURESKIN))
		drawTextureCylinder(0.4, 0.2, 0.2);
	else drawCylinder(0.4, 0.2, 0.2);
	glPopMatrix();

	glPushMatrix();
	glTranslated(-UPPER_TORSO_RADIUS - 0.2, 0.8, 0);
	if (VAL(TEXTURESKIN))
		drawTextureSphere(0.4);
	else drawSphere(0.4);
	glPopMatrix();
}
示例#2
0
static char* print_str_list(const m_option_t* opt, const void* src) {
  char **lst = NULL;
  char *ret = NULL,*last = NULL;
  int i;

  if(!(src && VAL(src))) return NULL;
  lst = VAL(src);

  for(i = 0 ; lst[i] ; i++) {
    if(last) {
      ret = dup_printf("%s,%s",last,lst[i]);
      free(last);
    } else
      ret = strdup(lst[i]);
    last = ret;
  }
  if(last && last != ret) free(last);
  return ret;
}
示例#3
0
struct LocationRef create_LR_first( RStore *in_store, obj item )
{
  struct LocationRef lr;
  struct VMPageRecord *vmpr;
  struct FirstPageHdr *fph = FIRST_PAGE_HDR_OF(VAL(item));

  assert( OBJ_ISA_PTR(item) );

  assert( in_store == fph->area->owner );

  vmpr = fph->vmpr;

  lr.base_page_num = vmpr->ref.base_page_num;
  lr.nth_page = vmpr->ref.nth_page;
  lr.first = vmpr->ref.first;
  lr.offset = VAL(item) - (UINT_32)vmpr->mem_address;
  lr.indirect = 0;
  return lr;
}
示例#4
0
文件: list.c 项目: marcomaggi/ucl
static void UCL_UNUSED
print_list (ucl_node_t N)
{
  ucl_node_t	M = NULL;
  for (; N; N = M) {
    M = ucl_list_cdr(N);
    fprintf(stderr, "%d, ", VAL(N));
  }
  fprintf(stderr, "\n");
}
示例#5
0
void SampleModel::drawNeck() {
	glPushMatrix();
	glTranslated(0, UPPER_TORSO_RADIUS + 0.1, 0);
	glScaled(0.4, 0.6, 0.4);
	glTranslated(-0.5, -0.5, -0.5);
	if (VAL(TEXTURESKIN))
		drawTextureBox(1, 1, 1);
	else drawBox(1, 1, 1);
	glPopMatrix();
}
示例#6
0
void Timer<ID>::init(void) {
  // Set Waveform Generator Mode to Normal
  // Set Prescaler to 0
  REG(timer<ID>::control) = 
    CFG(timer<ID>::control::wgm::normal) |
      CFG(timer<ID>::control::prescaler::template value<1>);
  
  // Set Counter to 0
  REG(timer<ID>::counter) = VAL(timer<ID>::counter, 0);
}
示例#7
0
文件: hash.c 项目: dongyx/hyphen
void *hash_set(hash_t tab, void *key, void *val) {
	unsigned h = MODHASH(tab, key);
	list_iter_t i = locate(tab, key, h);

	if (enditer(i)) {
		struct hash_node *ele = (struct hash_node*)malloc(sizeof *ele);
		ele->key = key;
		ele->val = val;
		ele->cont = tab;
		ele->hash = h;
		list_insert(list_container(i), i, ele);
		return 0;
	}
	else {
		void *old = VAL(i);
		VAL(i) = val;
		return old;
	}
}
示例#8
0
/*
 * anysumto returns the index (0 <= i < n) of the card in hand that brings
 * the s up to t, or -1 if there is none
 */
int
anysumto(CARD hand[], int n, int s, int t)
{
	int i;

	for (i = 0; i < n; i++) {
		if (s + VAL(hand[i].rank) == t)
			return (i);
	}
	return (-1);
}
示例#9
0
void SampleModel::drawRightLegJoint() {
	glPushMatrix();
	glTranslated(0.5, -UPPER_TORSO_RADIUS - 0.4, 0);
	glRotated(48, 0.0, 0.0, 1.0);
	glRotated(90, 1.0, 0.0, 0.0);
	glTranslated(0, 0, -0.3);
	if (VAL(TEXTURESKIN))
		drawTextureCylinder(0.7, 0.2, 0.2);
	else drawCylinder(0.7, 0.2, 0.2);
	glPopMatrix();
}
示例#10
0
void SampleModel::drawLowerTorso() {
	glPushMatrix();
	glTranslated(0, -UPPER_TORSO_RADIUS, 0); // move down
	glRotated(90, 1.0, 0.0, 0.0);
	glTranslated(0, 0, -0.4);
	if (VAL(TEXTURESKIN))
		drawTextureCylinder(LOWER_TORSO_HEIGHT, 0.9, 0.8);
	else drawCylinder(LOWER_TORSO_HEIGHT, 0.9, 0.8);

	glPopMatrix();
}
示例#11
0
void SampleModel::drawEyeBandana() {
	setDiffuseColor(COLOR_RED);
	glPushMatrix();
	glTranslated(0, UPPER_TORSO_RADIUS + HEAD_RADIUS + 0.3, 0);
	drawTorus(0.3, 0.5);
	glPopMatrix();
	if (VAL(NINJATURTLE))
		setDiffuseColor(COLOR_GREEN);
	else
		setDiffuseColor(.940f, .816f, .811f);
}
示例#12
0
// Parser for func_param and func_full
static int parse_func_pf(const m_option_t* opt,const char *name, char *param, void* dst, int src) {
  m_func_save_t *s,*p;

  if(!dst)
    return 1;

  s = calloc(1,sizeof(m_func_save_t));
  s->name = strdup(name);
  s->param = param ? strdup(param) : NULL;

  p = VAL(dst);
  if(p) {
    for( ; p->next != NULL ; p = p->next)
      /**/;
    p->next = s;
  } else
    VAL(dst) = s;

  return 1;
}
示例#13
0
文件: fhash.c 项目: rthelen/tyForth
void fhash_print(fenv_t *f, fobj_t *p)
{
    ASSERT(p->type == FOBJ_HASH);
    fhash_t *h = &p->u.hash;

    for (int i = 0; i < h->num_kv; i++) {
        fobj_print(f, KEY(h, i));
        printf(" = ");
        fobj_print(f, VAL(h, i));
    }
}
示例#14
0
int problema6EleDiagoCor(matriz* mRes, const matriz* matOri, int a, int b){
	crea_mat(mRes,matOri->ren,1);
	int i;
	for (i = 0; i < matOri->ren; ++i)
	{
		VAL (mRes,i,0)=VAL(matOri,a,b);
		a+=1;
		b+=1;
		if (a>matOri->ren-1)
		{
			a-=matOri->ren;
			b-=matOri->ren;
		}
		if (b>matOri->col-1)
		{
			b-=matOri->col;
		}
	}
	return OK;
}
示例#15
0
static void set_func_full(const m_option_t* opt, void* dst, void* src) {
  m_func_save_t* s;

  if(!src) return;

  for(s = VAL(src) ; s ; s = s->next) {
    // Revert if needed
    if(opt->priv) ((m_opt_default_func_t)opt->priv)(opt,s->name);
    ((m_opt_func_full_t) opt->p)(opt,s->name,s->param);
  }
}
示例#16
0
int main()
{
  _10: LET A$ = "";
  _40: LET B = 12;
  _20: INPUT "What is your name? ", A$;
  _50: INPUT "How old are you? ", B;
  _60: PRINT "Hello ", A$, " who is ", B, " years old";
  _70: LET C$ = STR(B);
  _80: LET D = VAL(C$);
  _90: PRINT "C$ = ", C$, " D = ", D;
}
示例#17
0
文件: lu.c 项目: ccotter/libdeterm
static void print(mtype *arr)
{
	int i;
	for (i = 0; i < n; ++i) {
		int j;
		for (j = 0; j < n; ++j) {
			printf("%.8Lf ", VAL(arr, i, j));
		}
		printf("\n");
	}
}
示例#18
0
int problema10Ajedrez(matriz* mRes, const matriz* matOri, int a, int b){
	crea_mat(mRes,1,matOri->col);
	int i;
	for (i = 0; i < matOri->col; ++i)
	{
		VAL (mRes,0,i)=VAL(matOri,a,b);
		a+=2;
		b+=1;
		if (a>matOri->ren-1)
		{
			a-=matOri->ren;

		}
		if (b>matOri->col-1)
		{
			b-=matOri->col;
		}
	}
	return OK;
}
示例#19
0
/* create_block_tree:
 * Construct block tree by peeling nodes from block list in state.
 * When done, return root. The block list is empty
 * FIX: use largest block as root
 */
block_t *createBlocktree(Agraph_t * g, circ_state * state)
{
    block_t *bp;
    block_t *next;
    block_t *root;
    int min;
    /* int        ordercnt; */

    find_blocks(g, state);

    bp = state->bl.first;	/* if root chosen, will be first */
    /* Otherwise, just pick first as root */
    root = bp;

    /* Find node with minimum VAL value to find parent block */
    /* FIX: Should be some way to avoid search below.               */
    /* ordercnt = state->orderCount;  */
    for (bp = bp->next; bp; bp = next) {
	Agnode_t *n;
	Agnode_t *parent;
	Agnode_t *child;
	Agraph_t *subg = bp->sub_graph;

	child = n = agfstnode(subg);
	min = VAL(n);
	parent = PARENT(n);
	for (n = agnxtnode(subg, n); n; n = agnxtnode(subg, n)) {
	    if (VAL(n) < min) {
		child = n;
		min = VAL(n);
		parent = PARENT(n);
	    }
	}
	SET_PARENT(parent);
	CHILD(bp) = child;
	next = bp->next;	/* save next since list insertion destroys it */
	appendBlock(&(BLOCK(parent)->children), bp);
    }
    initBlocklist(&state->bl);	/* zero out list */
    return root;
}
示例#20
0
// We are going to override (is that the right word?) the draw()
// method of ModelerView to draw out RobotArm
void RobotArm::draw()
{
	/* pick up the slider values */

	float theta = VAL( BASE_ROTATION );
	float phi = VAL( LOWER_TILT );
	float psi = VAL( UPPER_TILT );
	float cr = VAL( CLAW_ROTATION );
	float h1 = VAL( BASE_LENGTH );
	float h2 = VAL( LOWER_LENGTH );
	float h3 = VAL( UPPER_LENGTH );
	float pc = VAL( PARTICLE_COUNT );


    // This call takes care of a lot of the nasty projection 
    // matrix stuff
	ModelerView::draw();
	static GLfloat lmodel_ambient[] = { 0.4, 0.4, 0.4, 1.0 };
	Mat4f temp = getModelViewMatrix();

	// define the model

	ground(-0.2);
	
	if (true) {
		Ariou();
	} else {
		base(0.8);

	    glTranslatef( 0.0, 0.8, 0.0 );			// move to the top of the base
	    glRotatef( theta, 0.0, 1.0, 0.0 );		// turn the whole assembly around the y-axis. 
		rotation_base(h1);						// draw the rotation base

	    glTranslatef( 0.0, h1, 0.0 );			// move to the top of the base
	    glRotatef( phi, 0.0, 0.0, 1.0 );		// rotate around the z-axis for the lower arm
		glTranslatef( -0.1, 0.0, 0.4 );
		lower_arm(h2);							// draw the lower arm

	    glTranslatef( 0.0, h2, 0.0 );			// move to the top of the lower arm
	    glRotatef( psi, 0.0, 0.0, 1.0 );		// rotate  around z-axis for the upper arm
		upper_arm(h3);							// draw the upper arm

		glTranslatef( 0.0, h3, 0.0 );
		glRotatef(cr, 0.0, 0.0, 1.0);
		claw(1.0);
		SpawnParticles(temp);
	}

	//*** DON'T FORGET TO PUT THIS IN YOUR OWN CODE **/
	endDraw();
}
示例#21
0
/*
 * return the number of cards in h having the given rank value
 */
int
numofval(CARD h[], int n, int v)
{
	int i, j;

	j = 0;
	for (i = 0; i < n; i++) {
		if (VAL(h[i].rank) == v)
			++j;
	}
	return (j);
}
示例#22
0
文件: eval.c 项目: samsonjs/lake
static LakeVal *_or(LakeCtx *ctx, Env *env, LakeList *expr)
{
  /* drop the "or" symbol */
  list_shift(expr);

  /* (or ...) */
  LakeVal *result = LIST_N(expr) ? eval(ctx, env, list_shift(expr)) : VAL(ctx->F);
  while (lake_is_falsy(ctx, result) && LIST_N(expr) > 0) {
    result = lake_bool_or(ctx, result, eval(ctx, env, list_shift(expr)));
  }
  return result;
}
示例#23
0
struct LocationRef create_immob_LR( obj item )
{
  struct LocationRef lr;

  lr.base_page_num = VAL(item);
  lr.nth_page = 0;
  lr.first = 0;
  lr.indirect = 1;
  lr.offset = 0;

  return lr;
}
示例#24
0
文件: eval.c 项目: samsonjs/lake
LakeVal *apply(LakeCtx *ctx, LakeVal *fnVal, LakeList *args)
{
  LakeVal *result = NULL;
  if (lake_is_type(TYPE_PRIM, fnVal)) {
    LakePrimitive *prim = PRIM(fnVal);
    int arity = prim->arity;
    if (arity == ARITY_VARARGS || LIST_N(args) == arity) {
      result = prim->fn(ctx, args);
    }
    else {
      ERR("%s expects %d params but got %zu", prim->name, arity, LIST_N(args));
      result = NULL;
    }
  }
  else if (lake_is_type(TYPE_FN, fnVal)) {
    LakeFn *fn = FN(fnVal);

    /* Check # of params */
    size_t nparams = LIST_N(fn->params);
    if (!fn->varargs && LIST_N(args) != nparams) {
      ERR("expected %zu params but got %zu", nparams, LIST_N(args));
      return NULL;
    }
    else if (fn->varargs && LIST_N(args) < nparams) {
      ERR("expected at least %zu params but got %zu", nparams, LIST_N(args));
      return NULL;
    }

    Env *env = env_make(fn->closure);

    /* bind each (param,arg) pair in env */
    size_t i;
    for (i = 0; i < nparams; ++i) {
      env_define(env, SYM(LIST_VAL(fn->params, i)), LIST_VAL(args, i));
    }

    /* bind varargs */
    if (fn->varargs) {
      LakeList *remainingArgs = list_make_with_capacity(LIST_N(args) - nparams);
      for (; i < LIST_N(args); ++i) {
        list_append(remainingArgs, LIST_VAL(args, i));
      }
      env_define(env, fn->varargs, VAL(remainingArgs));
    }

    /* evaluate body */
    result = eval_exprs1(ctx, env, fn->body);
  }
  else {
    ERR("not a function: %s", lake_repr(fnVal));
  }
  return result;
}
示例#25
0
文件: eval.c 项目: samsonjs/lake
static LakeVal *_and(LakeCtx *ctx, Env *env, LakeList *expr)
{
  /* drop the "and" symbol */
  list_shift(expr);

  /* (and ...) */
  LakeVal *result = LIST_N(expr) ? eval(ctx, env, list_shift(expr)) : VAL(ctx->T);
  while (lake_is_truthy(ctx, result) && LIST_N(expr) > 0) {
    result = lake_bool_and(ctx, result, eval(ctx, env, list_shift(expr)));
  }
  return result;
}
示例#26
0
文件: GP_IO.c 项目: gfxprim/gfxprim
int gp_io_writef(gp_io *io, uint16_t *types, ...)
{
	va_list va;
	uint8_t *ptr, t;
	int32_t i4;
	int16_t i2;

	va_start(va, types);

	while (*types != GP_IO_END) {
		switch (TYPE(*types)) {
		case GP_IO_CONST:
			t = VAL(*types);
			if (gp_io_write(io, &t, 1) != 1)
				goto err;
		break;
		case GP_IO_L2:
		case GP_IO_B2:
			i2 = va_arg(va, int);
			ptr = (void*)&i2;

			if (needs_swap(*types))
				GP_SWAP(ptr[0], ptr[1]);

			if (gp_io_write(io, ptr, 2) != 2)
				goto err;
		break;
		case GP_IO_L4:
		case GP_IO_B4:
			i4 = va_arg(va, int);
			ptr = (void*)&i4;

			if (needs_swap(*types)) {
				GP_SWAP(ptr[0], ptr[3]);
				GP_SWAP(ptr[1], ptr[2]);
			}

			if (gp_io_write(io, ptr, 4) != 4)
				goto err;
		break;
		default:
			GP_WARN("Invalid type %"PRIu16"\n", *types);
			goto err;
		}
		types++;
	}

	va_end(va);
	return 0;
err:
	va_end(va);
	return -1;
}
示例#27
0
void SGJCLog(char *LogFileName, int numEvals, 
             unsigned fdim, const double *vals, const double *errs)
{ 
  int nf;
  FILE *f=fopen(LogFileName,"a");
  if (!f) return;
  fprintf(f,"** after %i function evaluations: \n",numEvals);
  for (nf=0; nf<fdim; nf++)
   fprintf(f,"%3i: %+12.4e \\pm %5.1e\n",nf,VAL(nf),ERR(nf));
  fprintf(f,"\n");
  fclose(f);
} 
示例#28
0
文件: lu.c 项目: ccotter/libdeterm
/* Serial LU decomposition. */
void *lu(void *_arg)
{
	struct luargs *args = _arg;
	int bi = args->bi;
	int bj = args->bj;
	int nbi = args->nbi;
	int nbj = args->nbj;
	int row0 = bi * n / nbi;
	int col0 = bj * n / nbj;
	int row1 = row0 + n / nbi;
	int col1 = col0 + n / nbj;

	int i;
	for (i = row0; i < row1; ++i) {
		int j;
		for (j = col0; j < col1; ++j) {
			int k;
			for (k = 0; k < min(i, j); ++k) {
				VAL(A, i, j) -= VAL(L, i, k) * VAL(A, k, j);
			}
			if (i > j) {
				VAL(L, i, j) = VAL(A, i, j) / VAL(A, j, j);
			}
		}
	}
	return NULL;
}
示例#29
0
文件: GP_IO.c 项目: gfxprim/gfxprim
static void readf_size(uint16_t *types,
                       unsigned int *min_size, unsigned int *max_size)
{
	unsigned int min = 0;
	unsigned int max = 0;

	while (*types != GP_IO_END) {
		switch (TYPE(*types)) {
		case GP_IO_CONST:
		case GP_IO_BYTE:
			min++;
			max++;
		break;
		case GP_IO_L2:
		case GP_IO_B2:
			min += 2;
			max += 2;
		break;
		case GP_IO_L4:
		case GP_IO_B4:
			min += 4;
			max += 4;
		break;
		case GP_IO_ARRAY:
		case GP_IO_IGN:
			min += VAL(*types);
			max += VAL(*types);
		break;
		case GP_IO_PPSTR:
			min += 2;
			max += 255;
		break;
		}
		types++;
	}

	*min_size = min;
	*max_size = max;
}
示例#30
0
文件: lu.c 项目: ccotter/libdeterm
static void check(mtype *a, mtype *b)
{
	int i;
	for (i = 0; i < n; ++i) {
		int j;
		for (j = 0; j < n; ++j) {
			if (fabs(VAL(a, i, j) - VAL(b, i, j)) > EPS) {
				printf("Not correct %d %d\n", i, j);
				printf("%Lf %Lf\n", VAL(a,i,j), VAL(b,i,j));
				print(R);
				printf("\n");
				print(Orig);
				printf("\n");
				print(L);
				printf("\n");
				print(A);
				printf("\n");
				exit(1);
			}
		}
	}
}