예제 #1
0
파일: graphic.c 프로젝트: kdj0c/starc
void grBatchAddRot(vec_t p, float r, texc_t *tex, unsigned int c) {
	vec_t h2;
	vec_t w2;
	int o = 8 * count;

	if (count >= GR_MAX) {
		fprintf(stderr, "Warning too much draw in the queue\n");
		return;
	}

	h2 = vangle(tex->h / 2., r);
	w2 = vangle(tex->w / 2., r);

	lvert[o]     = p.x + h2.x - w2.y;
	lvert[o + 1] = p.y + h2.y + w2.x;
	lvert[o + 2] = p.x + h2.x + w2.y;
	lvert[o + 3] = p.y + h2.y - w2.x;
	lvert[o + 4] = p.x - h2.x + w2.y;
	lvert[o + 5] = p.y - h2.y - w2.x;
	lvert[o + 6] = p.x - h2.x - w2.y;
	lvert[o + 7] = p.y - h2.y + w2.x;

	memcpy(ltc + o, tex->texc, 8 * sizeof(float));

	o = 4 * count;
	lcolor[o] = c;
	lcolor[o + 1] = c;
	lcolor[o + 2] = c;
	lcolor[o + 3] = c;

	count++;
}
예제 #2
0
 double angle(CBundle* const &b) const {
     double ax=x1()-x0;
     double ay=y1()-y0;
     double bx=b->x1()-b->x0;
     double by=b->y1()-b->y0;
     return vangle(ax,ay,bx,by);
 }
예제 #3
0
파일: mothership.c 프로젝트: kdj0c/starc
void msRespawn(ship_t *sh, ship_t *ms, float time) {
	pos_t tmp;

	sh->health = sh->t->maxhealth;

	get_pos(time, &ms->traj, &tmp);

	sh->traj.base.p = vmatrix(tmp.p, ms->t->part[ms->t->hangar].p, tmp.r);
	sh->traj.base.r = tmp.r + ms->t->part[ms->t->hangar].r - M_PI_2;
	sh->traj.base.v = vadd(ms->pos.v, vangle(1., sh->traj.base.r));
	sh->traj.base.dr = 0.;
	sh->traj.basetime = time;
}
예제 #4
0
static void collide(sprite_t *this_sprite,
		    sprite_t *other_sprite,
		    int x, int y)
{
  sprite_t *s;
  float n[2];

  if (other_sprite->type == &missile)
    return;
  s = sprite_create(&dsmoke,NULL);
  sprite_set_pos(s,x,y);
  sprite_get_vel(this_sprite, n);
  s->anim_p = ((vangle(n) + 128) & 255)/8 ;
  sprite_get_vel(other_sprite,n);
  sprite_set_vel(s,n);
  sprite_group_insert(effects_group,s);
  sprite_kill(this_sprite);
}
예제 #5
0
 double yangle() const {
     double x=x1()-x0;
     double y=y1()-y0;
     double o=x<0?1:-1;
     return vangle(0,1,x,y)*o+M_PI;
 }
예제 #6
0
파일: sur227.c 프로젝트: mildred/Varkon
   DBstatus varkon_pat_rotloft (

/*-------------- Argument declarations -----------------------------*/
/*                                                                  */
/* In:                                                              */
   GMPATL *p_patl,       /* Pointer to the conic lofting patch      */
   DBint   icase,        /* Calculation case:                       */
                         /* Eq. 0: Only coordinates                 */
                         /* Eq. 1: Coordinates and dr/du derivative */
                         /* Eq. 2: Coordinates and dr/dv derivative */
                         /* Eq.  : All  derivatives                 */
   DBfloat u_pat,        /* Patch (local) U parameter value         */
   DBfloat v_pat,        /* Patch (local) V parameter value         */

   EVALS  *p_xyz )       /* Coordinates and derivatives       (ptr) */

/* Out:                                                             */
/*       Data to p_xyz                                              */
/*-----------------------------------------------------------------!*/

{ /* Start of function */

/*!--------------- Internal variables ------------------------------*/
/*                                                                  */
/*                                                                  */
/*-----------------------------------------------------------------!*/

   EVALS  xyz_tra;       /* Coordinates and derivatives transformed */
   char   errbuf[80];    /* String for error message fctn erpush    */
   short  status;        /* Error code from a called function       */

/* ----------------- Theory ----------------------------------------*/
/*                                                                  */
/* The coordinates and derivatives  ........................        */
/*                                                                  */
/*----------------------------------------------------------------- */

/*--------------end-of-declarations---------------------------------*/

/*!                                                                 */
/* Algorithm                                                        */
/* =========                                                        */
/*                                                                 !*/

#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC),
"sur227 Mid curve flag p_patl->p_flag %d\n", (int)p_patl->p_flag);
  fflush(dbgfil(SURPAC));
}
#endif

/*!                                                                 */
/* 1. Check of input data and initializations                       */
/* __________________________________________                       */
/*                                                                  */
/*  Initialize output coordinates and derivatives for DEBUG on.     */
/*  Call of initial.                                                */
/*                                                                 !*/

#ifdef DEBUG
   status=initial(p_patl,u_pat,v_pat,p_xyz); 
   if (status<0) 
   {
   sprintf(errbuf,"initial%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2973",errbuf));
   }
#endif

/*!                                                                 */
/*  Retrieve coordinate tolerance. Call of varkon_ctol (sur751)     */
/*                                                                 !*/

   ctol      = varkon_ctol();

/*!                                                                 */
/* 2. Calculate rotation system                                     */
/* ____________________________                                     */
/*                                                                  */
/* Call of r_csys.                                                  */
/*                                                                 !*/
   status= r_csys (p_patl); 
   if (status<0) 
   {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "sur227 r_csys failed \n" );
fflush(dbgfil(SURPAC));
}
#endif
   sprintf(errbuf,"r_csys%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2973",errbuf));
   }



/*!                                                                 */
/* 2. Calculate curve derivatives in local system                   */
/* ______________________________________________                   */
/*                                                                  */
/* Call of cderiv.                                                  */
/*                                                                 !*/
   status= cderiv (p_patl, u_pat); 
   if (status<0) 
   {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "sur227 cderiv failed \n" );
fflush(dbgfil(SURPAC));
}
#endif
   sprintf(errbuf,"cderiv%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2973",errbuf));
   }


/*!                                                                 */
/* 3. Calculate angle corresponding to input V value                */
/* _________________________________________________                */
/*                                                                  */
/* Call of vangle.                                                  */
/*                                                                 !*/
   status= vangle ( v_pat); 
   if (status<0) 
   {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "sur227 vangle failed \n" );
fflush(dbgfil(SURPAC));
}
#endif
   sprintf(errbuf,"vangle%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2973",errbuf));
   }


/*!                                                                 */
/* 4. Calculate surface derivatives in local system                 */
/* ________________________________________________                 */
/*                                                                  */
/* Call of sderiv.                                                  */
/*                                                                 !*/
   status= sderiv (); 
   if (status<0) 
   {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "sur227 sderiv failed \n" );
fflush(dbgfil(SURPAC));
}
#endif
   sprintf(errbuf,"sderiv%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2973",errbuf));
   }

/*!                                                                 */
/* 5. Transformation of derivatives                                 */
/* ________________________________                                 */
/*                                                                  */
/* Invertation of matrix and transformation of EVALS.               */
/* Call of varkon_geo_612 and varkon_evals_transf (sur640).         */
/*                                                                 !*/


status=GEtform_inv (&rot_csys, &rot_csys_inv );
   if (status<0) 
   {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "GEtform_inv failed \n" );
fflush(dbgfil(SURPAC));
}
#endif
   sprintf(errbuf,"GEtform_inv%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2943",errbuf));
   }

     xyz_s.e_case = 4;

status=varkon_evals_transf
     (&xyz_s, &rot_csys_inv, &xyz_tra );
   if (status<0) 
   {
#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
{
fprintf(dbgfil(SURPAC), "GEtform_inv failed \n" );
fflush(dbgfil(SURPAC));
}
#endif
   sprintf(errbuf,"GEtform_inv%%varkon_pat_rotloft (sur227)");
   return(varkon_erpush("SU2943",errbuf));
   }

/*  Coordinates          r(u)                                       */
    p_xyz->r_x= xyz_tra.r_x;
    p_xyz->r_y= xyz_tra.r_y;
    p_xyz->r_z= xyz_tra.r_z;


/*  Tangent             dr/du                                       */
    p_xyz->u_x=  xyz_tra.u_x;
    p_xyz->u_y=  xyz_tra.u_y;
    p_xyz->u_z=  xyz_tra.u_z;

/*  Tangent             dr/dv                                       */
    p_xyz->v_x= xyz_tra.v_x;
    p_xyz->v_y= xyz_tra.v_y;
    p_xyz->v_z= xyz_tra.v_z;

/*  Second derivative  d2r/du2                                      */
    p_xyz->u2_x= xyz_tra.u2_x;
    p_xyz->u2_y= xyz_tra.u2_y;
    p_xyz->u2_z= xyz_tra.u2_z;

/*  Second derivative  d2r/dv2                                      */
    p_xyz->v2_x= xyz_tra.v2_x;
    p_xyz->v2_y= xyz_tra.v2_y;
    p_xyz->v2_z= xyz_tra.v2_z;

/*  Twist vector       d2r/dudv                                     */
    p_xyz->uv_x= xyz_tra.uv_x;
    p_xyz->uv_y= xyz_tra.uv_y;
    p_xyz->uv_z= xyz_tra.uv_z;

   p_xyz->sp_x  = poi_spine.x_gm;
   p_xyz->sp_y  = poi_spine.y_gm;
   p_xyz->sp_z  = poi_spine.z_gm; 
   p_xyz->spt_x = tan_spine.x_gm;
   p_xyz->spt_y = tan_spine.y_gm;
   p_xyz->spt_z = tan_spine.z_gm;
   p_xyz->spt2_x= 0.0;
   p_xyz->spt2_y= 0.0;
   p_xyz->spt2_z= 0.0;


#ifdef DEBUG
if ( dbglev(SURPAC) == 1 )
  {
  fprintf(dbgfil(SURPAC),
  "sur227 r_x %f r_y %f r_z %f \n",
   p_xyz->r_x,p_xyz->r_y,p_xyz->r_z);
  fprintf(dbgfil(SURPAC),
  "sur227 u_x %f u_y %f u_z %f \n",
   p_xyz->u_x,p_xyz->u_y,p_xyz->u_z);
  fprintf(dbgfil(SURPAC),
  "sur227 v_x %f v_y %f v_z %f \n",
   p_xyz->v_x,p_xyz->v_y,p_xyz->v_z);
  fprintf(dbgfil(SURPAC),
  "sur227 u2_x %f u2_y %f u2_z %f \n",
   p_xyz->u2_x,p_xyz->u2_y,p_xyz->u2_z);
  fprintf(dbgfil(SURPAC),
  "sur227 v2_x %f v2_y %f v2_z %f \n",
   p_xyz->v2_x,p_xyz->v2_y,p_xyz->v2_z);
  fprintf(dbgfil(SURPAC),
  "sur227 uv_x %f uv_y %f uv_z %f \n",
   p_xyz->uv_x,p_xyz->uv_y,p_xyz->uv_z);
  }
if ( dbglev(SURPAC) == 1  )
  {
  fprintf(dbgfil(SURPAC),
  "sur227 Exit *** varkon_pat_rotloft x= %8.2f y= %8.2f z= %8.2f \n",
   p_xyz->r_x,p_xyz->r_y,p_xyz->r_z);
  fflush(dbgfil(SURPAC)); /* To file from buffer      */
  }
#endif

    return(SUCCED);

} /* End of function                                                */