std::string Ioss::Asym_Tensor_02::label(int which, const char) const
{
  assert(which > 0 && which <= component_count());
  switch(which) {
  case 1:  return XY();
  case 2:  return YZ();
  default: return "";
  }
}
示例#2
0
std::vector<Vector3D> Polygone::getPoints3D() const
{
    std::vector<Vector3D> res;
    int taille = nbPoints();
    res.reserve(taille);
    for(int i = 0;  i < taille; i++)
        res.push_back(Vector3D(XY(get(i)),0));
    return res;
}
示例#3
0
// blurColumns: perform a blur1d on each column of a rectangular matrix
void blurColumns(CRGB* leds, uint8_t width, uint8_t height, fract8 blur_amount)
{
    // blur columns
    uint8_t keep = 255 - blur_amount;
    uint8_t seep = blur_amount >> 1;
    for( uint8_t col = 0; col < width; col++) {
        CRGB carryover = CRGB::Black;
        for( uint8_t i = 0; i < height; i++) {
            CRGB cur = leds[XY(col,i)];
            CRGB part = cur;
            part.nscale8( seep);
            cur.nscale8( keep);
            cur += carryover;
            if( i) leds[XY(col,i-1)] += part;
            leds[XY(col,i)] = cur;
            carryover = part;
        }
    }
}
示例#4
0
static void show_rgb(){
	for(uint8_t j = 0; j < 8; j++){
		for(uint8_t i = 0; i < WIDTH; i++){
			leds[XY(i,j)] = CRGB::Red;
		}	
	}

	for(uint8_t j = 8; j < 16; j++){
		for(uint8_t i = 0; i < WIDTH; i++){
			leds[XY(i,j)] = CRGB::Green;
		}	
	}

	for(uint8_t j = 16; j < HEIGHT; j++){
		for(uint8_t i = 0; i < WIDTH; i++){
			leds[XY(i,j)] = CRGB::Blue;
		}	
	}
}
示例#5
0
static void rtbox(double r,double theta,double wtheta,const char *label) {
	coord v[4];
	double htheta,hr;
	
	htheta=wtheta/2;
	hr=r*htheta;
	v[0]=rt(r-hr,theta-htheta);
	v[1]=rt(r+hr,theta-htheta);
	v[2]=rt(r+hr,theta+htheta);
	v[3]=rt(r-hr,theta+htheta);
	
	startgroup();
	printf("<path "LT" d=\"M%f %f L%f %f L%f %f L%f %f Z\"/>\n",
		XY(v[0]),XY(v[1]),XY(v[2]),XY(v[3]));
	
	crosshair(rt(r,theta),5);
	text_cen(rt(r+0.8*hr,theta),theta,24,label);
	endgroup();
}
示例#6
0
文件: atilo.c 项目: osingla/atilo
/**
 * TBD
 * 
 * @param f_draw TBD
 * @param f_reset_history TBD
 */
void init_new_game( const int f_draw, const int f_reset_history ) {
    int k, x, y;

    /*--- By default, computer has black, play has white ---*/
    code_computer = CODE_WHITE;
    code_human = CODE_BLACK;
    color_to_play = CODE_BLACK; // Next color to play

    /*--- Initialize the board ---*/
    for ( k = 0; k < 9; k++ )
        board[XY( 0, k )] = board[XY( k, 9 )] = board[XY( 9, 9 - k )] = board[XY( 9 - k, 0 )] = CODE_AROUND;
    for ( x = 1; x <= 8; x++ )
        for ( y = 1; y <= 8; y++ )
            board[XY( x, y )] = CODE_EMPTY;
    board[XY( 4, 4 )] = CODE_WHITE;
    board[XY( 4, 5 )] = CODE_BLACK;
    board[XY( 5, 4 )] = CODE_BLACK;
    board[XY( 5, 5 )] = CODE_WHITE;

    /*--- Cumul time played by each color ---*/
    if ( f_reset_history ) {
        time( &t_start );       // Time when player starts thinking
        ctime_black = ctime_white = 0;
        show_horo(  );
    }

    /*--- Draw the complete board ---*/
    if ( f_draw )
        if ( board_drawing_area->window )
            redraw_board(  );
    compute_nb_pawns( f_draw );

    /*--- Show the possibilities of the player ---*/
    if ( f_draw )
        show_poss_play_cursor( code_human, code_computer );

    /*--- Reset history of the game ---*/
    if ( f_reset_history )
        clear_hist_list(  );

    /*--- Reset msg ---*/
    computer_infos_msg( " " );
    player_infos_msg( "Choose a position and click to play." );

    /*--- Disable the menu option 'Save the game' ---*/
    enable_SaveGame( FALSE );

}                               // init_new_game
std::string Ioss::Matrix_22::label(int which, const char) const
{
  assert(which > 0 && which <= component_count());
  switch(which) {
  case 1:  return XX();
  case 2:  return XY();
  case 3:  return YX();
  case 4:  return YY();
  default: return "";
  }
}
示例#8
0
//-----------------------------------------------------------------------------
void StamFluidSolver::MouseDown(float _u, float _v, int button)
{
    if(button > 4 || button < 0) return;
    int idx = XY(_u,_v);
    if(idx >= _gridCellsCount || idx < 0) {
        printf("idx out of bounds:%d\n",idx);
        return;
    }
    _touchLocations[button] = idx;
    //dens[idx] = 1.0f;
}
示例#9
0
文件: dither.c 项目: AbhiDGamer/mpv
static void makegauss(struct ctx *k, unsigned int sizeb)
{
    assert(sizeb >= 1 && sizeb <= MAX_SIZEB);

    memset(k, 0, sizeof(*k));
    av_lfg_init(&k->avlfg, 123);

    k->sizeb = sizeb;
    k->size = 1 << k->sizeb;
    k->size2 = k->size * k->size;

    k->gauss_radius = k->size / 2 - 1;
    k->gauss_middle = XY(k, k->gauss_radius, k->gauss_radius);

    unsigned int gauss_size = k->gauss_radius * 2 + 1;
    unsigned int gauss_size2 = gauss_size * gauss_size;

    for (index_t c = 0; c < k->size2; c++)
        k->gauss[c] = 0;

    double sigma = -log(1.5 / UINT64_MAX * gauss_size2) / k->gauss_radius;

    for (index_t gy = 0; gy <= k->gauss_radius; gy++) {
        for (index_t gx = 0; gx <= gy; gx++) {
            int cx = (int)gx - k->gauss_radius;
            int cy = (int)gy - k->gauss_radius;
            int sq = cx * cx + cy * cy;
            double e = exp(-sqrt(sq) * sigma);
            uint64_t v = e / gauss_size2 * UINT64_MAX;
            k->gauss[XY(k, gx, gy)] =
                k->gauss[XY(k, gy, gx)] =
                k->gauss[XY(k, gx, gauss_size - 1 - gy)] =
                k->gauss[XY(k, gy, gauss_size - 1 - gx)] =
                k->gauss[XY(k, gauss_size - 1 - gx, gy)] =
                k->gauss[XY(k, gauss_size - 1 - gy, gx)] =
                k->gauss[XY(k, gauss_size - 1 - gx, gauss_size - 1 - gy)] =
                k->gauss[XY(k, gauss_size - 1 - gy, gauss_size - 1 - gx)] = v;
        }
    }
    uint64_t total = 0;
    for (index_t c = 0; c < k->size2; c++) {
        uint64_t oldtotal = total;
        total += k->gauss[c];
        assert(total >= oldtotal);
    }
}
示例#10
0
文件: dither.c 项目: AbhiDGamer/mpv
// out_matrix is a reactangular tsize * tsize array, where tsize = (1 << size).
void mp_make_fruit_dither_matrix(float *out_matrix, int size)
{
    struct ctx *k = talloc(NULL, struct ctx);
    makegauss(k, size);
    makeuniform(k);
    float invscale = k->size2;
    for(index_t y = 0; y < k->size; y++) {
        for(index_t x = 0; x < k->size; x++)
            out_matrix[x + y * k->size] = k->unimat[XY(k, x, y)] / invscale;
    }
    talloc_free(k);
}
static void SoftkeyRender(const char* text, s3eDeviceSoftKeyPosition pos, void(*handler)())
{
    // TODO: Hardocoded font width and height (boo!)
    int width = 7;
    int height = 30;

    width *= strlen(text) * 2;
    int x = 0;
    int y = 0;
    switch (pos)
    {
        case S3E_DEVICE_SOFTKEY_BOTTOM_LEFT:
            y = IwGxGetScreenHeight() - height;
            x = 0;
            break;
        case S3E_DEVICE_SOFTKEY_BOTTOM_RIGHT:
            y = IwGxGetScreenHeight() - height;
            x = IwGxGetScreenWidth() - width;
            break;
        case S3E_DEVICE_SOFTKEY_TOP_RIGHT:
            y = 0;
            x = IwGxGetScreenWidth() - width;
            break;
        case S3E_DEVICE_SOFTKEY_TOP_LEFT:
            x = 0;
            y = 0;
            break;
    }

    CIwMaterial *fadeMat = IW_GX_ALLOC_MATERIAL();
    fadeMat->SetAlphaMode(CIwMaterial::SUB);
    IwGxSetMaterial(fadeMat);

    IwGxPrintString(x + 10, y+10, text, false);

    CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
    memset(cols, 50, sizeof(CIwColour)*4);

    if (s3ePointerGetState(S3E_POINTER_BUTTON_SELECT) & S3E_POINTER_STATE_PRESSED)
    {
        int pointerx = s3ePointerGetX();
        int pointery = s3ePointerGetY();
        if (pointerx >= x && pointerx <= x+width && pointery >=y && pointery <= y+height)
        {
            memset(cols, 15, sizeof(CIwColour)*4);
            handler();
        }
    }

    // Draw button area
    CIwSVec2 XY(x, y-2), dXY(width, height);
    IwGxDrawRectScreenSpace(&XY, &dXY, cols);
}
示例#12
0
文件: dither.c 项目: AbhiDGamer/mpv
static void print(struct ctx *k)
{
#if 0
    puts("#include <stdint.h>");
    printf("static const int mp_dither_size = %d;\n", k->size);
    printf("static const int mp_dither_size2 = %d;\n", k->size2);
    printf("static const uint16_t mp_dither_matrix[] = {\n");
    for(index_t y = 0; y < k->size; y++) {
        printf("\t");
        for(index_t x = 0; x < k->size; x++)
            printf("%4"PRIuFAST32", ", k->unimat[XY(k, x, y)]);
        printf("\n");
    }
    puts("};");
#else
    for(index_t y = 0; y < k->size; y++) {
        for(index_t x = 0; x < k->size; x++)
            r[XY(k, x, y)] = k->unimat[XY(k, x, y)];
    }
#endif
}
示例#13
0
文件: buffer.c 项目: 0x1p2/rpg-c
void bprintf(soul_t *ptr)
{
	while(buf->u == 0)
		;
	tools("clear", NULL);
	XY(15, 0);
	// printf(" THIS IS A STOP FOR THE MENU \n");	// Shows where buffer will end.
	XY(0, 0);
	menus(ptr, 1);
	menus(ptr->o, 1);
	printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
	for(int n = 0; n < STRINGS; n++)
	{
		if(buf->s[n] != NULL)
			printf(" %s \n", buf->s[n]);
	}
	printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
	buf->u = 0;
	menus(ptr, 2);
	menus(ptr->o, 2);
}
示例#14
0
glm::vec3 Material::GetImageColorInterp(const glm::vec2 &uv_coord, const QImage* const& image)
{
    if(image == NULL || uv_coord.x < 0 || uv_coord.y < 0 || uv_coord.x >= 1.0f || uv_coord.y >= 1.0f)
    {
        return glm::vec3(1,1,1);
    }
    else
    {
        //Use bilinear interp.

        float X = image->width() * uv_coord.x;
        float Y = image->height() * (1.0f - uv_coord.y);

        glm::vec2 floors = glm::vec2(floor(X), floor(Y));
        glm::vec2 ceils = glm::vec2(ceil(X), ceil(Y));
        ceils = glm::min(ceils, glm::vec2(image->width()-1, image->height()-1));
        QColor qll = image->pixel(floors.x, floors.y); glm::vec3 ll(qll.red(), qll.green(), qll.blue());
        QColor qlr = image->pixel(ceils.x, floors.y); glm::vec3 lr(qlr.red(), qlr.green(), qlr.blue());
        QColor qul = image->pixel(floors.x, ceils.y); glm::vec3 ul(qul.red(), qul.green(), qul.blue());
        QColor qur = image->pixel(ceils.x, ceils.y); glm::vec3 ur(qur.red(), qur.green(), qur.blue());

        float distX = (X - floors.x);
        glm::vec3 color_low = ll * (1-distX) + lr * distX;
        glm::vec3 color_high = ul * (1-distX) + ur * distX;

        float distY = (Y - floors.y);

        glm::vec3 result = (color_low * (1 - distY) + color_high * distY)/255.0f;

        return result;


        glm::vec2 XY(X,Y);
        //Want floor and ceil of both X and Y
        //Do square interp of <X,Y>

        float dist_ll = glm::distance(XY, floors);
        float dist_lr = glm::distance(XY, glm::vec2(ceils.x, floors.y));
        float dist_ul = glm::distance(XY, glm::vec2(floors.x, ceils.y));
        float dist_ur = glm::distance(XY, ceils);
        float sum = dist_ll + dist_lr + dist_ul + dist_ur;

        float llc = (1 - dist_ll/sum);
        float lrc = (1 - dist_lr/sum);
        float ulc = (1 - dist_ul/sum);
        float urc = (1 - dist_ur/sum);

        float checksum = llc + lrc + ulc + urc;

        glm::vec3 final_color = llc * ll + lrc * lr + ulc * ul + urc * ur;
        return final_color/255.0f;
    }
}
示例#15
0
void newGame(bool doLoadGame) {
  // Zero data store
  memset(&s_pieces, 0, BOARD_PIECES_X * BOARD_PIECES_Y * sizeof(Piece_t));
  memset(&s_score, 0, sizeof(Score_t));
  if (doLoadGame == true) {
    loadGame();
  } else { // new game
    // Init score
    s_score.level = 1;
    s_score.lives = 3;
    s_score.pointsToNextLevel = 200;
    s_score.nColoursActive = 5;
    #ifdef DEBUG_MODE
    s_score.nColoursActive = 3; // Allows to test long runs and interaction of special pieces with ease
    #endif
  }
  updateLevelColour();

  int offset = BOARD_SIZE_Y * SUB_PIXEL;
  for (int y = BOARD_PIECES_Y-1; y >= 0; --y) {
    for (int x = 0; x < BOARD_PIECES_X; ++x) {
      if (doLoadGame == false) {
        bool placing = true;
        while (placing) {
          s_pieces[ XY(x,y) ].colour = (rand() % s_score.nColoursActive) + 1;
          placing = checkLocation(GPoint(x,y)); // if match found then we're still placing as we need to try again
        }
      }
      s_pieces[ XY(x,y) ].loc.x = x * PIECE_SUB_PIXELS; // Set location
      s_pieces[ XY(x,y) ].loc.y = (y * PIECE_SUB_PIXELS) - offset; // Lets pieces fall in
    }
    offset += PIECE_SUB_PIXELS;
  }

  checkTiltMode();
  s_hintStatus = getHintStatus();  // Only want to read this once from store
  s_scoreState = kWait;
  s_gameState = kSettleBoard;
  s_gameOverMessage = false;
}
示例#16
0
文件: check.c 项目: kahrs/cda
void
setup(void)
{
	register i, j;
	register Pin *p;

	pininit();
	for(i = 0; i < 6; i++){
		if(b.v[i].npins == 0) continue;
		for(j = b.v[i].npins, p = b.v[i].pins; j > 0; j--, p++)
			pinlook(XY(p->p.x, p->p.y), i+1);
	}
}
std::string Ioss::Sym_Tensor_33::label(int which, const char) const
{
  assert(which > 0 && which <= component_count());
  switch(which) {
  case 1:  return XX();
  case 2:  return YY();
  case 3:  return ZZ();
  case 4:  return XY();
  case 5:  return YZ();
  case 6:  return ZX();
  default: return "";
  }
}
示例#18
0
Mesh PaterneQuad::remplissageBord(Vector2D &point1Batiment0, Vector2D &point2Batiment0, Vector2D &point2Batiment1, Vector2D &point3Batiment1)
{
    Mesh retour;

    float dExterne = distance( point1Batiment0, point3Batiment1);
    float dInterne = distance( point2Batiment0, point2Batiment1);

    Vector2D vecteurDirectionExt = (point3Batiment1 - point1Batiment0).normalised();
    Vector2D vecteurDirectionInt = (point2Batiment1 - point2Batiment0).normalised();

    if(dExterne > _par->minLargeurBatiment && dInterne > _par->minLargeurBatiment){

        int nbminBat = dExterne/_par->maxLargeurBatiment;
        int nbmaxBat = dExterne/_par->minLargeurBatiment;
        float aleatoire = 0;

        if(nbminBat != nbmaxBat){
            aleatoire = nbminBat + 1 + (rand()%(nbmaxBat-nbminBat));
        }
        else{
            aleatoire = nbminBat;
        }

        float largeurBatiment = dExterne / aleatoire;

        for(int i=0; i < aleatoire; i++){

            Vector2D p0 = point1Batiment0 + vecteurDirectionExt*i*largeurBatiment;
            Vector2D p1 = point1Batiment0 + vecteurDirectionExt*(i+1)*largeurBatiment;
            Vector2D p2 = point2Batiment0 + vecteurDirectionInt*distance(p1, point1Batiment0)*dInterne/dExterne;
            Vector2D p3 = point2Batiment0 + vecteurDirectionInt*distance(p0, point1Batiment0)*dInterne/dExterne;

            Batiment m = Batiment( Vector3D(XY(p0)), Vector3D(XY(p1)), Vector3D(XY(p2)), Vector3D(XY(p3)), _par );
            retour.merge(m.generate());
        }
    }
    return retour;
}
示例#19
0
inline void
clip_to_rect_one_step(const Polygon& polygon, Polygon& result, const Filter& filter)
{
    double sx, sy, px, py, bx, by;
    bool sinside, pinside;
    result.clear();

    if (polygon.size() == 0)
    {
        return;
    }

    sx = polygon.back().x;
    sy = polygon.back().y;
    for (Polygon::const_iterator i = polygon.begin(); i != polygon.end(); ++i)
    {
        px = i->x;
        py = i->y;

        sinside = filter.is_inside(sx, sy);
        pinside = filter.is_inside(px, py);

        if (sinside ^ pinside)
        {
            filter.bisect(sx, sy, px, py, &bx, &by);
            result.push_back(XY(bx, by));
        }

        if (pinside)
        {
            result.push_back(XY(px, py));
        }

        sx = px;
        sy = py;
    }
}
示例#20
0
bool settleBoard() {
  bool settled = true;
  for (int x=0; x < BOARD_PIECES_X; ++x) {
    for (int y=0; y < BOARD_PIECES_Y; ++y) {
      int floor = y * PIECE_PIXELS * SUB_PIXEL;
      if (s_pieces[XY(x,y)].loc.y < floor) { // Still needs to fall
        if (s_pieces[XY(x,y)].v == 0) s_pieces[XY(x,y)].v = PIECE_PIXELS * s_currentRun; // Keep the momentum going with a increasing initial speed
        s_pieces[XY(x,y)].v += GRAVITY;
        s_pieces[XY(x,y)].loc.y += s_pieces[XY(x,y)].v;
        settled = false;
      } else if (s_pieces[XY(x,y)].v > 0) { // Has fallen too far
        s_pieces[XY(x,y)].v = 0;
        s_pieces[XY(x,y)].loc.y = floor;
      } else { // Is in place. As we're searching top-down, everything below must also be in place too.
        break; // Efficiency - break the inner loop early
      }
    }
  }
  if (settled == true) s_gameState = kFindMatches;
  return true; // redraw, we're moving things
}
示例#21
0
void PhysicsObject::Drop(void)
{
	m_airborne = true;

	// Set spatial stats
	m_spatialKin.height = m_DropHeight;
	m_spatialKin.velocity.x = m_spatialKin.velocity.y = 0;
	
	// Compute the on-screen angle of travel
	m_screenKin.angle = ComputeScreenAngle();
	
	m_additiveScreenVelocity = XY (0, 0); 

	// Determine the on-screen velocities
	m_screenKin.velocity.x = m_additiveScreenVelocity.x;
	m_screenKin.velocity.y = m_additiveScreenVelocity.y + (m_spatialKin.velocity.y * -3/4); // Multiply by a negative as the axis for the coordinates are swapped
}
示例#22
0
int main(void)
{
  int y = 2;

  printf("%.3f, %d\n", CUBE(1.2), CUBE(y + 3));

  printf("%d, %d\n", NMOD_4(7.9), NMOD_4(17));

  printf("%.3f\n", XY(14.0,.3f));

  test_nelms_macro();

  test_toupper();

  test_disp();

  return 0;
}
示例#23
0
void RoomFire_Upper::Update(int delta)
{
	// Drop Snowflakes
	if (rand() % ASH_CHANCE == 0)
	{
		// Drop it above a random position within the world
		XY dropAbove = XY(
			rand()%int(m_Size.x-2*TILE_SIZE)+TILE_SIZE, 
			rand()%int(m_Size.y-5*TILE_SIZE)+4*TILE_SIZE
		);
		ParticleAsh* ashParticle = new ParticleAsh(x + dropAbove.x, y + dropAbove.y, 1000);
		//ParticleSimple* snowParticle = new ParticleSimple(100, 100, 100);

		g_game->addGameObject(ashParticle);

		ashParticle->Drop();
	}
}
   inline void callFunction(mxArray* plhs[], const mxArray*prhs[]) {
      if (!mexCheckType<T>(prhs[0])) 
         mexErrMsgTxt("type of argument 1 is not consistent");
      if (mxIsSparse(prhs[0])) 
         mexErrMsgTxt("argument 1 should be full");

      T* prX = reinterpret_cast<T*>(mxGetPr(prhs[0]));
      const mwSize* dimsX=mxGetDimensions(prhs[0]);
      long n=static_cast<long>(dimsX[0]);
      long M=static_cast<long>(dimsX[1]);

      plhs[0]=createMatrix<T>(n,M);
      T* prXY=reinterpret_cast<T*>(mxGetPr(plhs[0]));

      Matrix<T> X(prX,n,M);
      Matrix<T> XY(prXY,n,M);
      XY.copy(X);
      XY.invSym();
}
示例#25
0
void CEndGameState::Render()
{
    IW_CALLSTACK("CEndGameState::Render");

    IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);

    GetWorld().Render();

    IwGxLightingOff();
    IwGxSetScreenSpaceOrg( &CIwSVec2::g_Zero );

    CIwColour* cols = IW_GX_ALLOC(CIwColour, 4);
    memset(cols, 255, sizeof(CIwColour) * 4 );

    if (GetWorld().GetUICar()->GetPosition() == 1 )
    {
        CIwMaterial* mat = (CIwMaterial *)IwGetResManager()->GetGroupNamed("ui")->GetResNamed("youwin", IW_GX_RESTYPE_MATERIAL);
        IwGxSetMaterial(mat);
    }
    else
    {
        CIwMaterial* mat = (CIwMaterial *)IwGetResManager()->GetGroupNamed("ui")->GetResNamed("youlose", IW_GX_RESTYPE_MATERIAL);
        IwGxSetMaterial(mat);
    }


    const uint32 imageWidth  = 128;
    const uint32 imageHeight = 32;

    CIwSVec2 XY( (int16)((IwGxGetScreenWidth()/2) - (imageWidth/2)), (int16)(IwGxGetScreenHeight()/4) ),
            dXY( (int16)imageWidth, (int16)imageHeight );

    IwGxDrawRectScreenSpace(&XY, &dXY, cols);
    IwGxLightingOn();

    IwGxFlush();
    IwGxSwapBuffers();

#ifdef IW_DEBUG
    // Reset metrics for next frame
    IwGxMetricsReset();
#endif
}
示例#26
0
文件: mexBayer.cpp 项目: AVATOL/bat
   inline void callFunction(mxArray* plhs[], const mxArray*prhs[]) {
      if (!mexCheckType<T>(prhs[0])) 
         mexErrMsgTxt("type of argument 1 is not consistent");
      if (mxIsSparse(prhs[0])) 
         mexErrMsgTxt("argument 1 should not be sparse");

      T* prV = reinterpret_cast<T*>(mxGetPr(prhs[0]));
      const mwSize* dimsX=mxGetDimensions(prhs[0]);
      int n=static_cast<int>(dimsX[0]);
      int M=static_cast<int>(dimsX[1]);
      Vector<T> X(prV,n*M);
      const int offset = static_cast<int>(mxGetScalar(prhs[1]));

      plhs[0]=createMatrix<T>(n*M,1);
      T* prXY=reinterpret_cast<T*>(mxGetPr(plhs[0]));
      Vector<T> XY(prXY,n*M);
      XY.copy(X);
      XY.applyBayerPattern(offset);
}
示例#27
0
void SoRing::rayPick(SoRayPickAction * action)
{
  // Is it pickable ?
  if ( ! shouldRayPick(action) ) return;

  // compute the picking ray in our current object space
  computeObjectSpaceRay(action);

  SoPickedPoint* pp;
  SbVec3f intersection;
  SbPlane XY(SbVec3f(0,0,1),0);
  if ( XY.intersect(action->getLine(), intersection) )
  {
    float x, y, z;
    intersection.getValue(x, y, z);

    // back to the case of a disk centered at (0,0)
    float Xc, Yc;
    center.getValue().getValue(Xc,Yc);
    x -= Xc;
    y -= Yc;

    // within radius ?
    if ( sqrt(x*x+y*y+z*z) > outerRadius.getValue() ) return;
    if ( sqrt(x*x+y*y+z*z) < innerRadius.getValue() ) return;

    // within angular section ?
    float theta = sweepAngle.getValue();
    float angle = atan2(y,x);
    if ( angle < 0. ) angle += 2*M_PI;
    if ( theta != 360 && 
         angle*180.F/M_PI > theta ) return;

    if ( action->isBetweenPlanes(intersection) &&
         (pp = action->addIntersection(intersection)) != NULL )
    {
      pp->setObjectNormal(normal);
      pp->setObjectTextureCoords(SbVec4f(0.5f*(1+cos(angle)),
                                         0.5f*(1+sin(angle)), 0, 1));
    }
  }

}
示例#28
0
文件: check.c 项目: kahrs/cda
void
chkpins(Chip *c)
{
	register i, j;
	long bestd;
	short bpin;

	if(c->type->tt[0] == 0)
		return;
	for(i = 0; i < c->npins; i++)
		if(j = pinlook(XY(c->pins[i].p.x, c->pins[i].p.y), 0))
			if(c->type->tt[i] != ttnames[j-1]){
				nnprep(b.v[j-1].pins, b.v[j-1].npins);
				nn(c->pins[i].p, &bestd, &bpin);
				if(bestd)
					fprint(1, "*****check nn ERK!! get help %ld : %d\n", bestd, bpin);
				fprint(1, "%s.%d (tt=%c) coincides with %s.%d at %p\n",
					c->name, i+c->pmin, c->type->tt[i],
					b.v[j-1].name, bpin, c->pins[i].p);
			}
}
示例#29
0
void PhysicsObject::Launch(int angleSuppression, int speedOverride)
{
	m_airborne = true;

	// Call any overridden OnLaunch code
	OnLaunch();
	
	// The spatial launch angle
	m_spatialKin.SetAngleBySuppression(angleSuppression);

	// The scalar launch speed
	int speed = (speedOverride >= 0)? speedOverride : ComputeSpeedForDistance();

	// Derive the velocity from the speed and angle
	m_spatialKin.SetVelocityFromScalar(speed);
	
	// Compute the on-screen angle of travel
	m_screenKin.angle = ComputeScreenAngle();
	
	/* This is hard to explain: Image this as the velocity of the object's shadow along 
	the ground. The x and y values are the components of the spatial horizontal velocities. */
	m_additiveScreenVelocity = XY (
		m_spatialKin.velocity.x * cos(m_screenKin.angle),
		m_spatialKin.velocity.x * sin((m_pos.y > m_endPos.y) ? (m_screenKin.angle*-1) : m_screenKin.angle)
	); 

		// Determine the on-screen velocities
	// X is mapped directly as it is on screen
	m_screenKin.velocity.x = m_additiveScreenVelocity.x;

	/* 
	* Y is what you'd expect: 
	* The y component of the horiztonal spatial velocity, 
	* plus a fraction of the spatial vertical velocity
	*/
	m_screenKin.velocity.y = m_additiveScreenVelocity.y + (m_spatialKin.velocity.y * -3/4); 
}
示例#30
0
//-----------------------------------------------------------------------------
void StamFluidSolver::MouseDragged(float _u, float _v,float _lu, float _lv, int button)
{
    if(button > 4 || button < 0) return;
    int idx = XY(_u,_v);
    if(idx >= _gridCellsCount || idx < 0) {
        printf("idx out of bounds:%d\n",idx);
        return;
    }
    _touchLocations[button] = idx;

    //int i = (int)(_u * _NX);
    //int j = (int)(_v * _NY);

    //int li = (int)(_lu * _NX);
    //int lj = (int)(_lv * _NY);


    u[idx] = force * (_u-_lu);
    v[idx] = force * (_v-_lv);


    //DrawAntialiasedLine(dens, i, j, li, lj, 255);

}