示例#1
0
文件: xlib.c 项目: jacereda/glcv
static void openwin(int x, int y, unsigned w, unsigned h, int b) {
        XSizeHints hints;
        XSetWindowAttributes swa; 
        unsigned long swamask;
        Atom datom;
        swa.event_mask = EVMASK;
        swamask = CWEventMask;
        hints.x = x;
        hints.y = y;
        hints.width = w;
        hints.height = h;
        assert(!g_win);
        g_win = XCreateWindow(g_dpy, XRootWindow(g_dpy, scr()),
                            hints.x, hints.y, hints.width, hints.height,
                            0, CopyFromParent,
                            InputOutput, 
                            CopyFromParent,
                            swamask, &swa);
        borders(b);
        hints.flags = USSize | USPosition;
        XSetWMNormalHints(g_dpy, g_win, &hints);
        datom = XInternAtom(g_dpy, "WM_DELETE_WINDOW", False);
        XSetWMProtocols(g_dpy, g_win, &datom, 1);
        XSelectInput(g_dpy, g_win, EVMASK);
        g_xic = XCreateIC(g_xim,
                        XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
                        XNClientWindow, g_win,
                        XNFocusWindow, g_win,
                        NULL);
        if (g_cursor)
                XDefineCursor(g_dpy, g_win, g_cursor);
        XStoreName(g_dpy, g_win, (const char*)cvInject(CVQ_NAME, 0, 0));
}
示例#2
0
文件: auroraetheme.cpp 项目: KDE/kwin
int AuroraeTheme::topBorderMaximized() const
{
    int left, top, right, bottom;
    left = top = right = bottom = 0;
    borders(left, top, right, bottom, true);
    return top;
}
示例#3
0
void findpeaks( 
	       long environment, 
	       long listlength,
	       double *list, 
	       long *peakposes, 
	       long *peaknumber, 
	       double *thresh)



{
  long halfenv = environment / 2;
  long i;  
  *peaknumber = 0;
  long l,r;
  for (i=0;i<listlength;i++)
    { peakposes[i] = -2;}
  for (i=halfenv;i< (listlength-halfenv);i++){
    if (list[i]>=thresh[0] ) {
      borders(halfenv, listlength,i,&l,&r);
      if ( ismaxoflist( list[i],list, l, r) ){
	*peaknumber = *peaknumber + 1;
	peakposes[*peaknumber-1]=i;
	i = i+halfenv;
      }
    }
  }
}
示例#4
0
void BubbleDemo::run(EaLcdBoardGPIO& lcdBoard, uint32_t loops, uint32_t delayMs) {
  
  printf("BubbleDemo, %d loops, %dms delay\n", loops, delayMs);

    //update framebuffer
    graphics.setFrameBuffer(this->pFrmBuf);
    lcdBoard.setFrameBuffer((uint32_t)this->pFrmBuf);
    memset((void*)(pFrmBuf), 0, this->windowX * this->windowY * 2);

    for(int32_t n=0;n<loops;n++) {

        for(i = 0; i < NumBalls; i++) {
            x[i] += velX[i];
            y[i] += velY[i];
            
            for(j = i + 1; j < NumBalls; j++)
                collision();
                
            borders();
            
            if((int)x[i] != (int)oldX[i] || (int)y[i] != (int)oldY[i])
                draw();
        }

        wait_ms(delayMs);
    }
    memset((void*)(pFrmBuf), 0, this->windowX * this->windowY * 2);
}
示例#5
0
KDecoration::Position KDecoration::mousePosition(const QPoint &p) const
{
    const int range = 16;
    int bleft, bright, btop, bbottom;
    borders(bleft, bright, btop, bbottom);
    btop = KMIN(btop, 4); // otherwise whole titlebar would have resize cursor

    Position m = PositionCenter;

    if((p.x() > bleft && p.x() < widget()->width() - bright) && (p.y() > btop && p.y() < widget()->height() - bbottom))
        return PositionCenter;

    if(p.y() <= KMAX(range, btop) && p.x() <= KMAX(range, bleft))
        m = PositionTopLeft;
    else if(p.y() >= widget()->height() - KMAX(range, bbottom) && p.x() >= widget()->width() - KMAX(range, bright))
        m = PositionBottomRight;
    else if(p.y() >= widget()->height() - KMAX(range, bbottom) && p.x() <= KMAX(range, bleft))
        m = PositionBottomLeft;
    else if(p.y() <= KMAX(range, btop) && p.x() >= widget()->width() - KMAX(range, bright))
        m = PositionTopRight;
    else if(p.y() <= btop)
        m = PositionTop;
    else if(p.y() >= widget()->height() - bbottom)
        m = PositionBottom;
    else if(p.x() <= bleft)
        m = PositionLeft;
    else if(p.x() >= widget()->width() - bright)
        m = PositionRight;
    else
        m = PositionCenter;
    return m;
}
示例#6
0
文件: auroraetheme.cpp 项目: KDE/kwin
int AuroraeTheme::topBorder() const
{
    int left, top, right, bottom;
    left = top = right = bottom = 0;
    borders(left, top, right, bottom, false);
    return top;
}
示例#7
0
glm::uvec2 Indigo::NinePatch::min_size() const
{
	glm::uvec2 margins(m_margins.x + m_margins.z,m_margins.y + m_margins.w);
	glm::uvec2 borders(m_info->m_borders.x + m_info->m_borders.z,m_info->m_borders.y + m_info->m_borders.w);

	return glm::max(margins,borders);
}
示例#8
0
void Vehicle::update()
{
    wander();
    velocity += acceleration;
    velocity.limit( maxSpeed );
    position += velocity;
    acceleration.set( Vec2f::zero() );
    borders();
    angle = toDegrees( atan2f( velocity.y, velocity.x ) );
}
示例#9
0
//--------------------------------------------------------------------------------------------------
// buildNeighbors
void BasicSPH::buildNeighbors()
{
    // Reserve space and initialize neighbors' data
    _neighbors.clear();
    _neighbors.resize(_particles.size());

    // Init spatial grid
    Vec3d borders(_h*2.0, _h*2.0, _h*2.0);
    Vec3d gridMin = _volumeMin;
    gridMin -= borders;
    Vec3d gridMax = _volumeMax;
    gridMax += borders;
    SpatialGrid<long> grid(_h, gridMin, gridMax);

    // Insert particles into grid
    for (long p=0; p<_particles.size(); ++p)
    {
        grid.insert(p, _particles[p].pos);
    }

    // Use grid to retrieve neighbor particles
    double h2 = _h*_h;
    std::vector<long*> nearbyParticles;
    for (long p=0; p<_particles.size(); ++p)
    {
        const SPHParticle &particle = _particles[p];

        // Get nearby particles
        grid.getElements(particle.pos, _h, nearbyParticles);

        // Find particles that are within smoothing radius
        _neighbors[p].reserve(50);
        for (long i=0; i<nearbyParticles.size(); ++i)
        {
            long nID = *nearbyParticles[i];
            const SPHParticle &neighborParticle = _particles[nID];

            // Skip current particle
            if (nID==p)
                continue;

            Vec3d xij = particle.pos - neighborParticle.pos;

            // Check if distance is lower than smoothing radius
            double dist2 = xij.dot(xij);
            if (dist2 < h2)
            {
                // Yup! Add the particle to the neighbors list along with
                // some precomputed informations
                _neighbors[p].push_back(Neighbor(nID, xij, sqrt(dist2)));
            }
        }
    }
}
示例#10
0
void GOLWidget::paintGrid(QPainter &p) {
  QRect borders(0, 0, width() - 1, height() - 1);
  QColor gridColor = masterColor;
  p.setPen(gridColor);
  double cellWidth = (double)width() / size;
  double cellHeight = (double)height() / size;
  for (double k = cellWidth; k <= width(); k += cellWidth)
    p.drawLine(k, 0, k, height());
  for (double k = cellHeight; k <= height(); k += cellHeight)
    p.drawLine(0, k, width(), k);
  p.drawRect(borders);
}
示例#11
0
文件: camera.cpp 项目: NevrUSB/geoid
void Camera::setCameraOnObject()
{
	x2 = (borders().minX+borders().maxX)/2;
	y2 = (borders().minY+borders().maxY)/2;
	z2 = (borders().minZ+borders().maxZ)/2*m_zScale;
	calculateCameraCoordinates();
}
示例#12
0
void Boid::run(vector<Boid> boids, float separateForce, float alignForce, float cohesionForce,
                                   float separateRadious, float alignRadious, float cohesionRadious, float maxSpeed){
    this->separateForce = separateForce;
    this->alignForce = alignForce;
    this->cohesionForce = cohesionForce;
    this->separateRadious = separateRadious;
    this->alignRadious = alignRadious;
    this->cohesionRadious = cohesionRadious;
    this->maxSpeed = maxSpeed;
    flock(boids);
    update();
    borders();
}
示例#13
0
void GameWidget::paintGrid(QPainter &p)
{
    QRect borders(0, 0, width()-1, height()-1); // borders of the universe
    QColor gridColor = m_masterColor; // color of the grid
    gridColor.setAlpha(10); // must be lighter than main color
    p.setPen(gridColor);
    double cellWidth = (double)width()/universeSize; // width of the widget / number of cells at one row
    for(double k = cellWidth; k <= width(); k += cellWidth)
        p.drawLine(k, 0, k, height());
    double cellHeight = (double)height()/universeSize; // height of the widget / number of cells at one row
    for(double k = cellHeight; k <= height(); k += cellHeight)
        p.drawLine(0, k, width(), k);
    p.drawRect(borders);
}
示例#14
0
KDecorationDefines::Position AuroraeClient::mousePosition(const QPoint &point) const
{
    // based on the code from deKorator
    int pos = PositionCenter;
    if (isShade()) {
        return Position(pos);
    }

    int borderLeft, borderTop, borderRight, borderBottom;
    borders(borderLeft, borderRight, borderTop, borderBottom);
    int paddingLeft, paddingTop, paddingRight, paddingBottom;
    padding(paddingLeft, paddingRight, paddingTop, paddingBottom);
    const bool maximized = maximizeMode() == MaximizeFull && !options()->moveResizeMaximizedWindows();
    int titleEdgeLeft, titleEdgeRight, titleEdgeTop, titleEdgeBottom;
    AuroraeFactory::instance()->theme()->titleEdges(titleEdgeLeft, titleEdgeTop, titleEdgeRight, titleEdgeBottom, maximized);
    switch (AuroraeFactory::instance()->theme()->decorationPosition()) {
    case DecorationTop:
        borderTop = titleEdgeTop;
        break;
    case DecorationLeft:
        borderLeft = titleEdgeLeft;
        break;
    case DecorationRight:
        borderRight = titleEdgeRight;
        break;
    case DecorationBottom:
        borderBottom = titleEdgeBottom;
        break;
    default:
        break; // nothing
    }
    if (point.x() >= (m_view->width() -  borderRight - paddingRight)) {
        pos |= PositionRight;
    } else if (point.x() <= borderLeft + paddingLeft) {
        pos |= PositionLeft;
    }

    if (point.y() >= m_view->height() - borderBottom - paddingBottom) {
        pos |= PositionBottom;
    } else if (point.y() <= borderTop + paddingTop ) {
        pos |= PositionTop;
    }

    return Position(pos);
}
示例#15
0
void Boid::swarm(std::vector <Boid> v)
{
	/*		Lenard-Jones Potential function
	Vector R = me.position - you.position
	Real D = R.magnitude()
	Real U = -A / pow(D, N) + B / pow(D, M)
	R.normalise()
	force = force + R*U
	*/
	Pvector	R;
	Pvector sum(0, 0);

	// Your code here..

	applyForce(sum);
	update();
	borders();
}
示例#16
0
void gameW::paintGrid(QPainter &painter)
{
    QRect borders(0, 0, width()-1, height()-1);
    QColor gridColor = "#000";
    gridColor.setAlpha(40);
    painter.setPen(gridColor);
    double cellWidth = (double)width() / mapSize;
    for(double k = 0; k < width(); k += cellWidth)
    {
        painter.drawLine(k, 0, k, height());
    }
    double cellHeight = (double)height()/mapSize;
    for(double k = 0; k < height(); k += cellHeight)
    {
        painter.drawLine(0, k, width(), k);
    }
    painter.drawRect(borders);
}
示例#17
0
文件: game.c 项目: bpa/gamed
void do_attack(GameInstance *g, const Server *s, Player *p, SR_Command *cmd) {
	SpeedRiskData *risk = (SpeedRiskData *)g->data;
    SR_Game_Status *status = &risk->status;
	int attacking, defending, attack_loss, defend_loss, defender;
	if (not_holds(status, p, cmd->from)) {
		player_error(s, p, SR_ERR_NOT_OWNER);
	}
	else if (holds(status, p, cmd->to)) {
		player_error(s, p, SR_ERR_INVALID_DESTINATION);
	}
	else if (!borders(cmd->from, cmd->to)) {
		player_error(s, p, SR_ERR_INVALID_DESTINATION);
	}
	else if (cmd->armies < 1 || cmd->armies >= 
		status->countries[cmd->from].armies) {
		player_error(s, p, SR_ERR_NOT_ENOUGH_ARMIES);
	}
	else {
		attacking = cmd->armies > 3 ? 3 : cmd->armies;
		defending = status->countries[cmd->to].armies > 1 ? 2 : 1;
		roll_for_attack(attacking, defending, s->random, &attack_loss, &defend_loss);
		status->countries[cmd->from].armies -= attack_loss;
		status->countries[cmd->to].armies   -= defend_loss;
		defender = status->countries[cmd->to].owner;
		if (status->countries[cmd->to].armies == 0) {
			attacking = cmd->armies - attack_loss;
			status->countries[cmd->from].armies -= attacking;
			status->countries[cmd->to].armies += attacking;
			status->countries[cmd->to].owner = p->in_game_id;
			risk->players[p->in_game_id].countries_held++;
			risk->players[defender].countries_held--;
		}
		tell_all_mv_at_result(g, s, SR_CMD_ATTACK_RESULT, cmd->from, cmd->to);
		if (risk->players[defender].countries_held == 0) {
			all_cmd_f(g, s, SR_CMD_DEFEAT, defender);
			if (risk->players[defender].player != NULL) {
				s->log(g, "%s defeated", risk->players[defender].player->name);
			}
		}
		if (risk->players[p->in_game_id].countries_held == risk->board->territories) {
			s->change_state(g, &SR_DONE);
		}
	}
}
示例#18
0
//--------------------------------------------------------------
void vehicle::applyBehaviours(vector<vehicle> vehicles, ofVec2f* gradient){

    ofPoint mouse(ofGetMouseX(), ofGetMouseY());
    
    ofPoint separateForce = separate(vehicles);
    ofPoint seekForce = seek(mouse);
    ofPoint border = borders();
    ofPoint slope = slopes(gradient);
    
    separateForce*=2;
    seekForce *= 1;
    border *=3;
    slope *= 2;
    
    applyForce(slope);
    applyForce(border);
    applyForce(separateForce);
    applyForce(seekForce);
}
示例#19
0
void lifeWidget::paintGrid(QPainter &p)
{
    QRect borders(0, 0, width()-1, height()-1);
    QColor gridColor = Qt::blue; //m_masterColor;
    gridColor.setAlpha(10);
    p.setPen(gridColor);

    double cellWidth = (double)width()/universeSize;
    
    for(double k = cellWidth; k <= width(); k += cellWidth)
    {
        p.drawLine(k, 0, k, height());
    }
    double cellHeight = (double)height()/universeSize;
    for(double k = cellHeight; k <= height(); k += cellHeight)
    {
        p.drawLine(0, k, width(), k);
    }
    
    p.drawRect(borders);
}
示例#20
0
文件: vesadriver.c 项目: seL4/camkes
/* This function is invoked by the main CAmkES thread in this component. */
int run(void)
{
    int error = camkes_io_port_ops(&io_port_ops);
    assert(!error);

    /* Use the dataport address */
    void *bga_ptr = (void *)mock_hdmi;

    bga = bga_init(bga_ptr, out16, in16);
    bga_set_mode(bga, 1024, 768, 24); /* 1024x768 resolution at 24 BPP */

    ringbuffer_t *low = rb_new((void *)low_input, sizeof(*low_input));
    if (low == NULL) {
        abort();
    }

    ringbuffer_t *high = rb_new((void *)high_input, sizeof(*high_input));
    if (high == NULL) {
        abort();
    }

    borders();

    /* Check both inputs for data and pass it to the relevant framebuffer. */
    while (true) {
        char c;

        if ((c = (char)rb_poll_byte(low)) != 0) {
            write_low(c);
        }

        if ((c = (char)rb_poll_byte(high)) != 0) {
            write_high(c);
        }
    }

    return 0;
}
示例#21
0
文件: game.c 项目: bpa/gamed
void do_move(GameInstance *g, const Server *s, Player *p, SR_Command *cmd) {
	int armies;
	SpeedRiskData *risk = (SpeedRiskData *)g->data;
	SR_Game_Status *status = &risk->status;
	if (!(holds(status, p, cmd->from) && holds(status, p, cmd->to))) {
		player_error(s, p, SR_ERR_NOT_OWNER);
	}
	else if (!borders(cmd->from, cmd->to)) {
		player_error(s, p, SR_ERR_INVALID_DESTINATION);
	}
	else if (cmd->armies>=status->countries[cmd->from].armies){
		player_error(s, p, SR_ERR_NOT_ENOUGH_ARMIES);
	}
	else {
		armies = status->countries[cmd->to].armies + cmd->armies;
		if (armies > 255)
			cmd->armies = 255 - status->countries[cmd->to].armies;
		status->countries[cmd->from].armies -= cmd->armies;
		status->countries[cmd->to].armies   += cmd->armies;
		tell_all_mv_at_result(g, s, SR_CMD_MOVE_RESULT,
			cmd->from, cmd->to);
	}
}
示例#22
0
文件: Predator.cpp 项目: DaveMold/AI
void Predator::Draw(sf::RenderWindow &w, sf::Vector2f &wb)
{
    borders();
    sprite.setPosition(sf::Vector2f(location->x, location->y));
    w.draw(sprite);
}
示例#23
0
文件: imd_qc.c 项目: CBegau/imd
void generate_qc( void )
{
  real c=0.80,d=0.5;                        /* constants */
  int a1,a2,a3,a4,a5,a6,a7,a8;              /* grid boundaries */
  int hv,i,j;                               /* auxiliary variables */
  int p[3],q[3];                            /* approximant */
  int no,np,na,nb,nc,nt;                    /* geometry numbers */
  real tau[3],betrag[3],tau0[3],tau1[3];    /* grid vectors */
  real perkah[3];                           /* period in grid space */
  real tautl;                               /* golden number */
  real tautl0,tautl1,betrtl;                /* tiling vectors (lt) */
  real box[3];
  vektor cen;                               /* cell center */
  vektor perpro;                            /* per pe */

#ifndef BUFCELLS

  ivektor cpu_dim;
  int num_cpus = 0;
  int myid = 0;
  ivektor my_coord;

  /* this can't possibly work... */
  cpu_dim.x=1;
  cpu_dim.y=1;
  cpu_dim.z=1;

  /* this can't possibly work... */
  my_coord.x=0;
  my_coord.y=0;
  my_coord.z=0;

#endif  

  tautl = (sqrt(5.0)+1.0)*0.5;
  gam[0]=0.14;gam[1]=-0.25;gam[2]=0.33;gam[3]=-0.41;gam[4]=0.52;gam[5]=-0.33; 
  num_sort[0]=0;num_sort[1]=0;num_sort[2]=0;

 /* generating grid vectors */

 for (j=0;j<3;j++)
   {
      p[j] =1;q[j]=0;hv=0;
      for (i=0;i<appr[j];i++)
	{
	  hv=q[j];
          q[j]=p[j];
          p[j]=p[j]+hv;
	}
      tau[j]=((real) p[j])/((real) q[j]);
      perkah[j]=(tautl*p[j]+q[j])/sqrt(tautl+2.0);
#ifdef MPI
 if (0==myid)
   {
      printf("p(%1d)= %3d,q(%1d)= %3d,tau(%1d)= %3f\n",
	     j,p[j],j,q[j],j,tau[j]);
      printf("period in atomic units %10.5f\n",perkah[j]);
   };
#endif
   }

  for (i=0;i<3;i++)
    {
      betrag[i]=sqrt(tau[i]*tau[i]+1.0);
      tau0[i]=tau[i]/betrag[i];
      tau1[i]=1.0/betrag[i];
    } 
  gx[0]= tau0[0];gy[0]= 0;      gz[0]=-tau1[2];
  gx[1]= tau1[0];gy[1]= tau0[1];gz[1]= 0;
  gx[2]= 0;      gy[2]= tau1[1];gz[2]= tau0[2];
  gx[3]= 0;      gy[3]=-tau1[1];gz[3]= tau0[2];
  gx[4]= tau1[0];gy[4]=-tau0[1];gz[4]= 0;
  gx[5]= tau0[0];gy[5]= 0;      gz[5]= tau1[2];

  /* generating sort tiling vectors */
  
  betrtl=sqrt(tautl+2.0);
  tautl0=tautl/betrtl;tautl1=1.0/betrtl;
  tx[0]= tautl0;ty[0]= 0;     tz[0]=-tautl1;
  tx[1]= tautl1;ty[1]= tautl0;tz[1]= 0;
  tx[2]= 0;     ty[2]= tautl1;tz[2]= tautl0;
  tx[3]= 0;     ty[3]=-tautl1;tz[3]= tautl0;
  tx[4]= tautl1;ty[4]=-tautl0;tz[4]= 0;
  tx[5]= tautl0;ty[5]= 0;     tz[5]= tautl1;

  /* distributing computation */

  gmin.x=-perkah[0];gmax.x=perkah[0];
  gmin.y=-perkah[1];gmax.y=perkah[1];
  gmin.z=-perkah[2];gmax.z=perkah[2];
  
  perpro.x=(gmax.x-gmin.x)/((real) cpu_dim.x);
  perpro.y=(gmax.y-gmin.y)/((real) cpu_dim.y);
  perpro.z=(gmax.z-gmin.z)/((real) cpu_dim.z);
  
  for (i=0;i<3;i++) 
    {
      box[i]=4.0*perkah[i];
      iper[i]=1.0/box[i];
    }

      /* Set up 1 atom input cell */

      input = (cell *) malloc(sizeof(cell));
      if (0==input) error("Can't allocate input cell.") ;
      input->n_max=0;
      alloc_cell(input, 1);

      /* Set up cpu parts */

      cen.x=(2.*my_coord.x-cpu_dim.x+1.)*perpro.x*0.5*d;
      lmin.x=cen.x-perpro.x*0.5-c;
      lmax.x=cen.x+perpro.x*0.5+c;
      
      lmin.x=MAX(lmin.x,gmin.x);
      lmax.x=MIN(lmax.x,gmax.x);
      
      perm[0]=2.0*(my_coord.x*perpro.x);
      perp[0]=perm[0]+2.0*perpro.x;
      
      cen.y=(2.*my_coord.y-cpu_dim.y+1.)*perpro.y*0.5*d;
      lmin.y=cen.y-perpro.y*0.5-c;
      lmax.y=cen.y+perpro.y*0.5+c;

      lmin.y=MAX(lmin.y,gmin.y);
      lmax.y=MIN(lmax.y,gmax.y);
      
      perm[1]=2.0*(my_coord.y*perpro.y);
      perp[1]=perm[1]+2.0*perpro.y;
      
      cen.z=(2.*my_coord.z-cpu_dim.z+1.)*perpro.z*0.5*d;
      lmin.z=cen.z-perpro.z*0.5-c;
      lmax.z=cen.z+perpro.z*0.5+c;
      
      lmin.z=MAX(lmin.z,gmin.z);
      lmax.z=MIN(lmax.z,gmax.z);
      
      perm[2]=2.0*(my_coord.z*perpro.z);
      perp[2]=perm[2]+2.0*perpro.z;
      
      /* computing basic grid border parameters */
      
      for (j=0;j<6;j++)
	{
	  a1=floor(gx[j]*lmin.x+gy[j]*lmin.y+gz[j]*lmin.z-gam[j]+0.5);
	  a2=floor(gx[j]*lmax.x+gy[j]*lmax.y+gz[j]*lmax.z-gam[j]+0.5);
	  a3=floor(gx[j]*lmin.x+gy[j]*lmax.y+gz[j]*lmin.z-gam[j]+0.5);
	  a4=floor(gx[j]*lmax.x+gy[j]*lmin.y+gz[j]*lmax.z-gam[j]+0.5);
	  a5=floor(gx[j]*lmin.x+gy[j]*lmin.y+gz[j]*lmax.z-gam[j]+0.5);
	  a6=floor(gx[j]*lmax.x+gy[j]*lmax.y+gz[j]*lmin.z-gam[j]+0.5);
	  a7=floor(gx[j]*lmin.x+gy[j]*lmax.y+gz[j]*lmax.z-gam[j]+0.5);
	  a8=floor(gx[j]*lmax.x+gy[j]*lmin.y+gz[j]*lmin.z-gam[j]+0.5);
	  k1min[j]=MIN(MIN(MIN(a1,a2),MIN(a3,a4)),MIN(MIN(a5,a6),MIN(a7,a8)));
	  k1max[j]=MAX(MAX(MAX(a1,a2),MAX(a3,a4)),MAX(MAX(a5,a6),MAX(a7,a8)));
	}      
      natoms=0;
      nactive=0;
      
      borders();
      
      adjust();

      printf("Number of PE, number of atoms: %d %d\n",myid,natoms);
}
示例#24
0
文件: Boid.cpp 项目: MrMdR/julapy
void Boid :: run ()
{
	update();
	borders();
}
示例#25
0
// Run flock() on the flock of boids.
// This applies the three rules, modifies velocities accordingly, updates data,
// and corrects boids which are sitting outside of the SFML window
void Boid::run(vector <Boid> v)
{
	flock(v);
	update();
	borders();
}
示例#26
0
void mexFunction (int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    if(nlhs!=1)
    {
        mexErrMsgTxt("One matrix is needed as an output");
    }
    if(nrhs!=1)
    {
        mexErrMsgTxt("One double matrix is needed as an input");
    }
    if(!mxIsDouble(prhs[0]))
    {
        mexErrMsgTxt("The input must be a double typed matrix");
    }
    
////////////////////////////////////////////////////////////////////////////////
////////////////////////// CONSTANT PARAMETER DEFINITION////////////////////////
////////////////////////////////////////////////////////////////////////////////

//During the optimal sigma parameter guess phase each sigma such that
//sigma=SIGMA_MIN+k*DELTAT and sigma<=SIGMA_MAX will be tested.

    const int SIGMA_MIN=0; // minimal std-dev of the Gaussian-weighting function
    const int SIGMA_MAX=8; //maximal std-dev of the Gaussian-weighting function
    const float DELTA=0.5; //step between two consecutive std-dev




////////////////////////////////////////////////////////////////////////////////
////////////////////////// READ IMAGE///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

    int w1=mxGetN(prhs[0]);
    int h1=mxGetM(prhs[0]);
    
    float* Image= new float[w1*h1];
    int tmp=0;
	 int tmpx, tmpy;
    for (tmpx=0; tmpx<w1; tmpx++) 
       for (tmpy=0; tmpy<h1; tmpy++) 
	 	   Image[tmpx+tmpy*w1] = (float)(mxGetPr(prhs[0]))[tmpy+tmpx*h1];


////////////////////////////////////////////////////////////////////////////////
//////////////DEALING WITH BORDER EFFECTS: MIRROR symmetry ON COLUMNS////////////
////////////////////////////////////////////////////////////////////////////////




    int W=w1+8*SIGMA_MAX;
//new  width of image afer mirror symmetry : 4 times SIGMA_MAX on each sides
    float* Imsym= new float[W*h1]; //new image allocation

//input : image, New image, width,height, total size of the extension
    borders(Image,Imsym,w1,h1,4*SIGMA_MAX); //Output :
//Classic mirror symmetry on columns :
//    C1 C2 ... CN => C2 C1 |C1 C2 ... CN|CN CN-1 etc





////////////////////////////////////////////////////////////////////////////////
//////////////////////////TRANSFERING DATAS TO CENTRAL FUNCTION/////////////////
////////////////////////////////////////////////////////////////////////////////

//input image , width (after symetrication), height
    MIRE_automatic(Imsym,W,h1,SIGMA_MIN, SIGMA_MAX, DELTA);




////////////////////////////////////////////////////////////////////////////////
///////////REMOVING THE SYMETRIZATION : CROP (see DEALING WITH BORDERS//////////
////////////////////////////////////////////////////////////////////////////////



//#pragma omp parallel for
// The following realize a CROP
    for (unsigned column=0;column<w1;column++)  // for all columns
    {
        for (unsigned line=0;line<h1;line++)  // for all lines
        {
            Image[line*w1+column]
            =Imsym[line*(w1+8*SIGMA_MAX)+column+4*SIGMA_MAX];
// using the useless memory of the input
        }
    }

    delete [] Imsym;


////////////////////////////////////////////////////////////////////////////////
//////////////////////////////DYNAMIC CORRECTION////////////////////////////////
///////////////////////////////IMPOSING/////////////////////////////////////////
///////////////////////////////[0,255]//////////////////////////////////////////


//Computing the min and max of the output
    float min=Image[0];
    float max=Image[0];
//#pragma omp parallel for
    for (unsigned i=1;i<w1*h1;i++)
    {
        if (Image[i]<min) min=Image[i];
        if (Image[i]>max) max=Image[i];
    }


//Actually changing image-values
//#pragma omp parallel for
    for (unsigned i=1;i<w1*h1;i++)
    {
        Image[i]=(255*(Image[i]-min)/(max-min));
    }


////////////////////////////////////////////////////////////////////////////////
//////////////////////////////WRITING THE OUTPUT////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
    
    mwSize dim = 2;
    const mwSize dims[2]={h1,w1};
    plhs[0]=mxCreateNumericArray(dim, dims, mxDOUBLE_CLASS, mxREAL);
    double* pointeur=(double*)mxGetPr(plhs[0]);
    for (tmpy=0; tmpy<h1; tmpy++) 
       for (tmpx=0; tmpx<w1; tmpx++) 
       {
      	   pointeur[tmpy+tmpx*h1]=(double)Image[tmpx+tmpy*w1];
       }

    delete [] Image;

}
示例#27
0
文件: camera.cpp 项目: NevrUSB/geoid
void Camera::setDefaultCamera()
{
	cam_a = (GLdouble)pi/2;
	cam_b = (GLdouble)pi/4;
	cam_r = 1.5*(borders().maxX-borders().minX);
}
示例#28
0
文件: Boid.cpp 项目: jamtot/CPP
void Boid::run(vector<Boid*>& boids)
{
    flock(boids);
    update();
    borders();
}