void check_sphere(t_item *item, t_pd *s, t_inter *inter, int impactmod) { FLOAT_SIZE a; FLOAT_SIZE b; FLOAT_SIZE c; FLOAT_SIZE del; FLOAT_SIZE t; (void)impactmod; a = carre(s->dir.x) + carre(s->dir.y) + carre(s->dir.z); b = 2 * (s->dir.x * (s->pos.x - item->sp->c.x) + s->dir.y * (s->pos.y - item->sp->c.y) + s->dir.z * (s->pos.z - item->sp->c.z)); c = (carre(s->pos.x - item->sp->c.x) + carre(s->pos.y - item->sp->c.y) + carre(s->pos.z - item->sp->c.z)) - carre(item->sp->ray); del = carre(b) - (4 * a * c); if (del > 0) { t = ft_minspe((-b - sqrt(del)) / (2 * a), (-b + sqrt(del)) / (2 * a)); if (check_t(inter, t, s, item) == 1 && 1) { set_normal_sphere(inter, item); if (item->texture) set_texture_sphere(inter, item); } } return ; }
/* * Use after recvfrom() function. If received packet is not wrong, * i.e neither delayed or bogus, It updates check field corresponding * received password. */ void UpdateEntry(checkEntry* header, rcv_form* rcv) { checkEntry *temp; for (temp=header->next; temp != NULL; temp=temp->next) { if (temp->passwd == rcv->resp.passwd) { temp->check = check_t(rcv->resp.ret); break; } } }
/* * Add new password entry that just sent * It uses after sendto() function, * check field is set to NOT_RECEIVED. * Entry is linked list, and every new packet linked to * after the header. */ void AddEntry(checkEntry* header, uint32_t passwd) { checkEntry *temp; temp = (checkEntry *)malloc(sizeof(checkEntry)); temp->passwd = passwd; temp->check = check_t(NOT_RECEIVED); if (header->next == NULL) { temp->next = NULL; header->next = temp; } else { temp->next = header->next; header->next = temp; } }
static int cdf_dt (lua_State *L) { /* stack should contain x and df */ lua_Number x = luaL_checknumber(L, 1); lua_Number df = luaL_checknumber(L, 2); lua_Number t = 0.5; lua_Number d; check_t(L, 1, x, df); d = df/2; d = -dlnbet(&d, &t)-(df+1)/2*log(1+x*x/df); d = exp(d)/sqrt(df); lua_pushnumber(L, d); return 1; }
static int stat_pt (lua_State *L) { /* stack should contain t and df */ lua_Number t = luaL_checknumber(L, 1); lua_Number df = luaL_checknumber(L, 2); lua_Number p, q, bound; int which = 1; int status; check_t(L, 1, t, df); cdft(&which, &p, &q, &t, &df, &status, &bound); check_status(L, status, bound); lua_pushnumber(L, p); return 1; }
static int cdf_qt (lua_State *L) { /* stack should contain p and df */ lua_Number p = luaL_checknumber(L, 1); lua_Number df = luaL_checknumber(L, 2); lua_Number t; check_t(L, 2, p, df); if (p==0 || p==1) t = (p==0) ? -HUGE_VAL : HUGE_VAL; else { lua_Number q = 1-p; lua_Number bound; int which = 2; int status; cdft(&which, &p, &q, &t, &df, &status, &bound); check_status(status, bound); } lua_pushnumber(L, t); return 1; }
void check_cyl(t_item *item, t_pd *s, t_inter *inter, int impactmod) { FLOAT_SIZE a; FLOAT_SIZE b; FLOAT_SIZE c; FLOAT_SIZE t; t_vec l; l = sub_vec(s->pos, item->cyl->pos); a = dot_prod(s->dir, s->dir) - (dot_prod(s->dir, item->cyl->dir) * dot_prod(s->dir, item->cyl->dir)); b = 2 * (dot_prod(s->dir, l) - (dot_prod(s->dir, item->cyl->dir) * dot_prod(l, item->cyl->dir))); c = dot_prod(l, l) - (dot_prod(l, item->cyl->dir) * dot_prod(l, item->cyl->dir)) - item->cyl->ray * item->cyl->ray; if ((t = (b * b - 4.0 * a * c)) <= 0) return ; t = ft_minspe(((-b + sqrt(t)) / (2 * a)), ((-b - sqrt(t)) / (2 * a))); if (check_t(inter, t, s, item) == 1 && impactmod) set_normal_cyl(item->cyl, inter); return ; }
void check_triangle(t_item *item, t_pd *s, t_inter *inter, t_thr *f) { t_vec n; t_vec a; FLOAT_SIZE t; n = (prod_vector(item->tr->u, item->tr->v)); a.x = -dot_prod(n, sub_vec(s->pos, item->tr->p1)); a.y = dot_prod(n, s->dir); if (fabs(a.y) > 0 && (t = a.x / a.y) >= 0) { n = sub_vec(set_dist_pos(t, s->dir, s->pos), item->tr->p1); a.x = dot_prod(n, item->tr->u); a.y = dot_prod(n, item->tr->v); a.z = (a.y * item->tr->uv - item->tr->vv * a.x) / item->tr->d; a.y = (item->tr->uv * a.x - item->tr->uu * a.y) / item->tr->d; if (a.z < 0.0 || a.z > 1.0 || a.y < 0.0 || (a.y + a.z) > 1.0) return ; if (check_t(inter, t, s, item) == 1 && f->impactmod) inter->norm = item->tr->n; } return ; }
void execution(int argc,char* argv[]) { int in=0 ,io=0 ,copy_flag=0 , flag_fname=0; char f[6]; in_len=argc; flag_h=0; flag_d=0; d_value=0; flag_f=0; for(in=0; in< in_len ;in++) { strcpy(input_arra[in],argv[in]); } // printf("val of srgasdc is %d \n",in_len); flag_f=check_f(in_len); flag_h=check_h(in_len); flag_d=check_d(in_len); // printf("h is %d\n",flag_h); if(flag_h == 1) { printf("help karo\n"); return ; } if(in_len < 2) { printf("\n usage ./a.out inputfile<test.cap>\n"); return ; } if(flag_d == 0) { strcpy(inputfile,argv[in_len-1]); } else { d_value=atoi(argv[in_len-1]); //printf("d_value is %d \n\n",d_value); strcpy(inputfile,argv[in_len-3]); } //check filename exists or not //printf("filename is %s",inputfile); flag_fname=check_filename(); if(flag_fname == 1 ) { printf("\n input file name is wrong\n"); return; } for(in=0;in<30;in++) strcpy(runtimecmd[in]," "); cmd_flag=0; int len=0; //printf("number is %d \n\n",in_len); if(flag_d==1) len=in_len-3; else len=in_len-1; if(flag_f != 0) { cmd_flag=1; // printf("cmd is jgjnade %d us %d jhkj \n",flag_f,in_len); io=0; for(in=flag_f;in<len;in++) { //printf("insied "); strcpy(runtimecmd[io],input_arra[in]); io++; } // for(in=0;in<in_len;in++) // printf("runtime is %s ",runtimecmd[in]); }// printf("\n"); int ret, check_ret=0; check_ret=get_data(); //return 1; if(check_ret==1) return; int checkt =-1, checkf=0; int checkfst=0; //number of words in input int inputsize=in_len; strcpy(user_input,input_arra[1]); printdata(); while(1) { //printf("inside while"); checkt=-1; checkf=0; //checkf=check_f(inputsize); if(checkfst==1) { strcpy(user_input,""); //checkfst=1; printf(" \n enter the new commnad \n "); //scanf(" %s ",input_value); int j=0,m=0; for(m=0;m<100;m++) { for(j=0;j<100;j++) input_arra[m][j]='\0'; } char c; for (m=0;m<100;) { for(j=0;j<100;j++) { scanf("%c",&c); if(c==' ') { m++; break; } if(c=='\n') break; input_arra[m][j]=c; } if(c=='\n')break; } inputsize=m; //for( j=0;j<=m;j++) // printf("in put is %s \n",input_arra[j]); strcpy(user_input,input_arra[0]); } checkt=check_t(inputsize); if(!strcmp(user_input,"exit")) break; else if(!strcmp(user_input,"help")) { printf("\n am in help \n"); } else if(checkt !=-1 && checkfst == 1) { // printf("t is present at pos %ddsf and in put size is %d \n",checkt , inputsize); testcase(checkt,inputsize); } else { if(checkfst==1) { printf("wrong command entered \n"); } } checkfst=1; } }