virtual void getAllParameters(std::vector<double>& v) const
    {
        check(kVals_.size() >= 2, "");
        check(kVals_.size() == amplitudes_.size(), "");

        int nPar = 4 + 2 * kVals_.size() - 2;

        v.resize(nPar);

        std::vector<double>::iterator it = v.begin();
        *(it++) = getOmBH2();
        *(it++) = getOmCH2();
        *(it++) = getH();
        *(it++) = getTau();

        for(int i = 1; i < kVals_.size() - 1; ++i)
        {
            check(it < v.end(), "");
            *(it++) = std::log(kVals_[i]);
        }

        for(int i = 0; i < amplitudes_.size(); ++i)
        {
            check(it < v.end(), "");
            *(it++) = std::log(amplitudes_[i] * 1e10);
        }

        check(it == v.end(), "");
    }
    virtual void getAllParameters(std::vector<double>& v) const
    {
        int nPar = 6;

        if(varyNEff_)
            ++nPar;
        if(varySumMNu_)
            ++nPar;

        v.resize(nPar);

        std::vector<double>::iterator it = v.begin();
        *(it++) = getOmBH2();
        *(it++) = getOmCH2();
        *(it++) = getH();
        *(it++) = getTau();
        *(it++) = getNs();
        *(it++) = std::log(getAs()*1e10);

        if(varyNEff_)
            *(it++) = nEff_;

        if(varySumMNu_)
            *(it++) = sumMNu_;

        check(it == v.end(), "");
    }
bool ImageLoader::OverrideByName(const std::string& name, const std::shared_ptr<LunaImage>& img)
{
    // If we're mapping through an HDC, find it for this image name
    {
        auto it = m_NameToHDC.find(name);
        if (it != m_NameToHDC.end()) {
            if (img)
            {
                m_GfxOverride[it->second] = img;
            }
            else
            {
                m_GfxOverride.erase(it->second);
            }

            // Update height/width based on override
            auto categoryIterator = m_HDCToCategoryAndIndex.find(it->second);
            if (categoryIterator != m_HDCToCategoryAndIndex.end())
            {
                const SMBXImageCategory* category = categoryIterator->second.first;
                uint32_t idx = categoryIterator->second.second;

                if (img)
                {
                    category->setHeight(idx, img->getH());
                    category->setWidth(idx, img->getW());
                }
                else
                {
                    auto currentImg = ImageLoader::GetByName(name);
                    if (currentImg)
                    {
                        category->setHeight(idx, currentImg->getH());
                        category->setWidth(idx, currentImg->getW());
                    }
                }
            }

            return true;
        }
    }

    // Otherwise, for "extra gfx" we're mapping directly from name to image, so set the override that way
    if (m_ExtraGfx.find(name) != m_ExtraGfx.end())
    {
        if (img)
        {
            m_ExtraGfxOverride[name] = img;
        }
        else
        {
            m_ExtraGfxOverride.erase(name);
        }

        return true;
    }

    return false;
}
Exemple #4
0
void GroupOfButtons::addButton(string _text, void(*_fn)(), Color _color)
{
    button_w = max(button_w, al_get_text_width(font(font_size), _text.c_str()) + space()*5);

    objectsSequence.push_back(1);
    buttons.push_back(Button(_text, _fn, Area(), [=]()->Color{return _color == Color::null() ? default_color : _color;}()));

    for (int i = 0, b = buttons.size(), t = textboxes.size(); i < objectsSequence.size(); ++i) {
        if (objectsSequence[objectsSequence.size()-i-1]) {
            buttons[--b].reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
            buttons[b].reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
        } else {
            textboxes[--t].box.reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
            textboxes[t].box.reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
        }
    }
}
Exemple #5
0
void GroupOfButtons::addTextbox(string* pText, string _text)
{
    button_w = max(button_w, al_get_text_width(font(font_size), _text.c_str()) + space()*5);

    objectsSequence.push_back(0);
    textboxes.push_back(MyTextbox(Textbox(font_size, Area(), _text, default_color, false), pText));

    for (int i = 0, b = buttons.size(), t = textboxes.size(); i < objectsSequence.size(); ++i) {
        if (objectsSequence[objectsSequence.size()-i-1]) {
            buttons[--b].reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
            buttons[b].reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
        } else {
            textboxes[--t].box.reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
            textboxes[t].box.reInit(Area::CXYWH, cx, cy + getH()/2 - (button_h+space())*(i+1) + button_h/2, button_w, button_h);
        }
    }
}
Exemple #6
0
/*******************
  Expande ou a altura
  ou a largura, dependendo
  do parametro
*******************/
void Bitmap :: printFullScreen(int x, int y, int flag)
{
  if(sprite != NULL)
  {
    switch(flag)
    {
      case 0:
        al_draw_scaled_bitmap(sprite, 0, 0, getW(), SCREEN_H, x, y, SCREEN_W, SCREEN_H, 0);
        break;
      case 1:
        al_draw_scaled_bitmap(sprite, 0, 0, SCREEN_W, getH(), x, y, SCREEN_W, SCREEN_H, 0);
        break;
      case 2:
        al_draw_scaled_bitmap(sprite, 0, 0, getW(), getH(), x, y, SCREEN_W, SCREEN_H, 0);
        break;
    }
  }
}
Exemple #7
0
void CSulGuiTextBox::setTextOffset( float x, float y )
{
	m_ofs_x = x;
	m_ofs_y = y;

	if ( m_rText.valid() )
	{
		float h = getH();
		m_rText->setXY( 0+m_ofs_x, h-m_ofs_y );
	}
}
Exemple #8
0
BITMAP * Objets::getProprietes(int p_x,int p_y, int p_w, int p_h) {
    clear_to_color(proprietes,makecol(255,255,255));
    rect(proprietes,1,1,149,199,0);
    textprintf_ex(proprietes, font,35,10, makecol(0, 0, 0),makecol(255, 255, 255), "Proprietes");
    line(proprietes,0,20,200,20,0);
    textprintf_ex(proprietes, font,10,30, makecol(0, 0, 0),makecol(255, 255, 255), "Type : %s",nom);
    int _x,_y,_z;
    _x=(getX()-p_x);
    _y=(getY()-p_y);
    _z=getZ();

    if (!Tx->getSaisie())
        Tx->setValeur(_x);
    if (!Ty->getSaisie())
        Ty->setValeur(_y);
    if (!Tz->getSaisie())
        Tz->setValeur(_z);
    if (!Tw->getSaisie())
        Tw->setValeur(getW());
    if (!Th->getSaisie())
        Th->setValeur(getH());
    if (!Td->getSaisie())
        Td->setValeur(getD());

    textprintf_ex(proprietes, font,10,45, makecol(0, 0, 0),makecol(255, 255, 255), "x =");
    blit(Tx->getImage(),proprietes,0,0,Tx->getX(),Tx->getY(),Tx->getW(),Tx->getH());
    textprintf_ex(proprietes, font,10,60, makecol(0, 0, 0),makecol(255, 255, 255), "y =");
    blit(Ty->getImage(),proprietes,0,0,Ty->getX(),Ty->getY(),Ty->getW(),Ty->getH());
    textprintf_ex(proprietes, font,10,75, makecol(0, 0, 0),makecol(255, 255, 255), "z =");
    blit(Tz->getImage(),proprietes,0,0,Tz->getX(),Tz->getY(),Tz->getW(),Tz->getH());
    textprintf_ex(proprietes, font,10,90, makecol(0, 0, 0),makecol(255, 255, 255), "Longueur =");
    blit(Tw->getImage(),proprietes,0,0,Tw->getX(),Tw->getY(),Tw->getW(),Tw->getH());
    textprintf_ex(proprietes, font,10,105, makecol(0, 0, 0),makecol(255, 255, 255), "Largeur =");
    blit(Th->getImage(),proprietes,0,0,Th->getX(),Th->getY(),Th->getW(),Th->getH());
    textprintf_ex(proprietes, font,10,120, makecol(0, 0, 0),makecol(255, 255, 255), "Hauteur =");
    blit(Td->getImage(),proprietes,0,0,Td->getX(),Td->getY(),Td->getW(),Td->getH());

    char *lesens;
    if (sens=="N")
        lesens="Nord";
    else if (sens=="E")
        lesens="Est";
    else if (sens=="S")
        lesens="Sud";
    else if (sens=="O")
        lesens="Ouest";
    textprintf_ex(proprietes, font,10,135, makecol(0, 0, 0),makecol(255, 255, 255), "Sens = %s",lesens);
    delete [] lesens;

    textprintf_ex(proprietes, font,10,150, makecol(0, 0, 0),makecol(255, 255, 255), "Couleur = ");
    rectfill(proprietes,90,148,100,158,q_c);
    rect(proprietes,90,148,100,158,0);
    return proprietes;
}
 virtual void getAllParameters(std::vector<double>& v) const
 { 
     v.resize(8);
     v[0] = getOmBH2();
     v[1] = getOmCH2();
     v[2] = getH();
     v[3] = getTau();
     v[4] = getNs();
     v[5] = std::log(getAs() * 1e10);
     v[6] = getNEff();
     v[7] = getSumMNu();
 }
Exemple #10
0
void HeaterMOO::erase ( double** src, double** dest ) {
  uint32_t h = getH ();
  uint32_t w = getW ();
#pragma omp parallel for if ( _omp )
  for ( size_t i = 0; i < w; i++ ) {
    for ( size_t j = 0; j < h; j++ ) {
      if ( src[i][j] != .0 ) {
        dest[i][j] = src[i][j];
      }
    }
  }
}
Exemple #11
0
/////////////////////
// destroy an engine
//
int EngineHandlers::destroy(EngHandle h)
{
	eh *ep = getH(h);
	if (ep) {
		ep->eng->closeall();
		delete ep->eng->get_db();
		delete ep->eng;
		ep->eng = 0;
		return 1;
	}
	return 0;
}
Exemple #12
0
void HeaterMOO::diffuse ( double** src, double** dest ) {
  // modèle 1: check les bounds
  uint32_t h = getH ();
  uint32_t w = getW ();
#pragma omp parallel for if ( _omp )
  for ( size_t i = 0; i < w; i++ ) {
    for ( size_t j = 0; j < h; j++ ) {
      double old = src[i][j];
      double neighbours = sumNeighbours ( src, i, j );
      dest[i][j] = old + _k * ( neighbours - ( 4 * old ) );
    }
  }
}
Exemple #13
0
void HeaterMOO::fillImage ( double** img ) {
  uint32_t h = getH ();
  uint32_t w = getW ();
  Calibreurs calibreur ( 0, 1, 0.7, 0 );
#pragma omp parallel for if ( _omp )
  for ( size_t i = 1; i <= w; i++ ) {
    for ( size_t j = 1; j <= h; j++ ) {
      double temperature = img[i - 1][j - 1];
      float hue = calibreur.calibrate ( temperature );
      setHue ( i, j, hue );
    }
  }
}
Exemple #14
0
void RipplingMOO::fillImage(float t)
    {
    int h = getH();
    int w = getW();
    
#pragma omp parallel for if ( _omp )
    for (int i = 1; i <= h; i++)
	{
	for (int j = 1; j <= w; j++)
	    {
	    setPixel(i, j, t);
	    }
	}
    }
Exemple #15
0
//==============================================================================
//                             MULTIPLY BY M
//==============================================================================
// The next two methods calculate x=M*v (or f=M*a) in O(N) time, given v.
// The first one is called base to tip.
// Cost is: pass1 12*dof+12 flops
//          pass2 11*dof+63 flops
//          total 23*dof + 75
// TODO: Possibly this could be much faster if composite body inertias R were
// precalculated along with D = ~H*R*H. Then I *think* this could be a single
// pass with tau = D*udot. Whether this is worth it would depend on how much
// this gets re-used after R and D are calculated.
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void 
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::multiplyByMPass1Outward(
    const SBTreePositionCache&  pc,
    const Real*                 allUDot,
    SpatialVec*                 allA_GB) const
{
    const Vec<dof>& udot = fromU(allUDot);
    SpatialVec&     A_GB = allA_GB[nodeNum];

    // Shift parent's A_GB outward. (Ground A_GB is zero.)
    const SpatialVec A_GP = ~getPhi(pc) * allA_GB[parent->getNodeNum()]; // 12 flops

    A_GB = A_GP + getH(pc)*udot;    // 12*dof flops
}
Exemple #16
0
bool Bounds::hasColidedWith(Bounds otherobj)
{
	//al_draw_filled_rectangle(getX(),getY(),getX() + getW(),getY() + getH(),al_map_rgb(255,255,255));
	//al_draw_filled_rectangle(otherobj.getX(),otherobj.getY(),otherobj.getX() + otherobj.getW(),otherobj.getY() + otherobj.getH(),al_map_rgb(255,255,255));
	if(	getX() < otherobj.getX() + otherobj.getW() &&
		getX() + getW() > otherobj.getX() &&
		getY() < otherobj.getY() + otherobj.getH() &&
		getY() + getH() > otherobj.getY())
	{
		//cout << "HIT:{" << getX() << "|" << getY() << "|" << getW() << "|" << getH() << "},{" << otherobj.getX() << "|" << otherobj.getY() << "|" << otherobj.getW() << "|" << otherobj.getH()  << endl;
		return true;
	}
	return false;
}
void RayTracingImageCudaMOO::fillImageGL()
    {
    int w = getW();
    int h = getH();

#pragma omp parallel for num_threads(numThreads)
    for (int i = 1; i <= h; i++)
	{
	for (int j = 1; j <= w; j++)
	    {
	    setPixel(i, j, t);
	    }
	}
    }
Exemple #18
0
void CSulGuiTextBox::init()
{
	CSulGuiCanvas::init();

	float h = getH();

	m_rText = new CSulGuiText( m_sText, 0+m_ofs_x, h-m_ofs_y, m_fontSize, m_font );
	m_rText->setColor( m_color );
	m_rText->init();
	addChild( m_rText );

	useShaderTexture( false );
	useShaderBorder( false );
	useShaderBackground( false );
}
Exemple #19
0
void Astar::addtoopen(int col,int row,int id)
{
    //向open列表中加入点
    AstarItem * temp = new AstarItem();
	temp->setpos(col,row);
	temp->setfid(id);
	int g = getG(col, row, id);
	int h = getH(col, row);
	temp->setg(g);
	temp->seth(h);
	temp->setf(g + h);
	open->addObject(temp);
	resetSort(open->count() - 1);

}
Exemple #20
0
//==============================================================================
//                       MULTIPLY BY SYSTEM JACOBIAN
//==============================================================================
// Calculate product of kinematic Jacobian J=~Phi*H and a mobility-space vector. Requires 
// that Phi and H are available, so this should only be called in Stage::Position or higher.
// This does not change the cache at all.
//
// Note that if the vector v==u (generalized speeds) then the result is V_GB=J*u, the
// body spatial velocities generated by those speeds.
//
// Call base to tip (outward).
//
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::
multiplyBySystemJacobian(
    const SBTreePositionCache&  pc,
    const Real*                 v,
    SpatialVec*                 Jv) const
{
    const Vec<dof>& in  = fromU(v);
    SpatialVec&     out = Jv[nodeNum];

    // Shift parent's result outward (ground result is 0).
    const SpatialVec outP = ~getPhi(pc) * Jv[parent->getNodeNum()]; // 12 flops

    out = outP + getH(pc)*in;  // 12*dof flops
}
Exemple #21
0
//==============================================================================
//                            CALC H_PB_G_DOT
//==============================================================================
// Same for all mobilizers.
// CAUTION: our H matrix definition is transposed from Jain and Schwieters. 
// Cost is 69 + 65*dof flops
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::
calcParentToChildVelocityJacobianInGroundDot(
    const SBModelVars&          mv,
    const SBTreePositionCache&  pc, 
    const SBTreeVelocityCache&  vc,
    HType&                      HDot_PB_G) const
{
    const HType& H_FM    = getH_FM(pc);
    const HType& HDot_FM = getHDot_FM(vc);

    // We want R_GF so we can reexpress the cross-joint velocity V_FB (==V_PB)
    // in the ground frame, to get V_PB_G.

    const Rotation& R_PF = getX_PF().R();       // fixed config of F in P

    // Calculated already since we're going base to tip.
    const Rotation& R_GP = getX_GP(pc).R();     // parent orientation in ground
    const Rotation  R_GF = (noR_PF ? R_GP : R_GP * R_PF); // 45 flops (TODO: again??)

    const Vec3& w_GF = getV_GP(vc)[0]; // F and P have same angular velocity

    // Note: time derivative of R_GF is crossMat(w_GF)*R_GF.
    //      H = H_PB_G =  R_GF * (H_FM + H_MB_F) (see above method)
    const HType& H_PB_G = getH(pc);
    if (noX_MB || noR_FM)
        HDot_PB_G = R_GF * HDot_FM // 48*dof
                  + HType(w_GF % H_PB_G[0], 
                          w_GF % H_PB_G[1]);
    else {
        // want r_MB_F, that is, the vector from OM to OB, expressed in F 
        const Vec3&     r_MB   = getX_MB().p();     // fixed
        const Rotation& R_FM   = getX_FM(pc).R();   // just calculated
        const Vec3      r_MB_F = (noR_FM ? r_MB : R_FM*r_MB); // 15 flops

        const Vec3& w_FM = getV_FM(vc)[0]; // local angular velocity

        HType HDot_MB_F;
        HDot_MB_F[0] = Vec3(0);
        HDot_MB_F[1] =          -r_MB_F  % HDot_FM[0] // 21*dof + 9 flops
                       - (w_FM % r_MB_F) % H_FM[0];


        HDot_PB_G =   R_GF * (HDot_FM + HDot_MB_F) // 54*dof
                    + HType(w_GF % H_PB_G[0], 
                            w_GF % H_PB_G[1]);
    }
}
Exemple #22
0
void Astar::addToOpen(int col, int row, int id)
{
    CC_ASSERT(_open != nullptr && "the open is nullptr");

    AstarItem* temp = AstarItem::create();
    temp->setPos(col, row);
    temp->setFid(id);
    int g = getG(col, row, id);
    int h = getH(col, row);
    temp->setG(g);
    temp->setH(h);
    temp->setF(g +h);
    _open->addObject(temp);

    resetSort(_open->count() - 1);
}
 virtual void getAllParameters(std::vector<double>& v) const
 {
     v.resize(5);
     v[0] = getOmBH2();
     v[1] = getOmCH2();
     v[2] = getH();
     v[3] = getTau();
     // kmin and kmax are fixed so don't return these
     v[4] = std::log(amplitudes_[0] * 1e10);
     for(int i = 1; i < kVals_.size() - 1; ++i)
     {
         v.push_back(std::log(kVals_[i]));
         v.push_back(std::log(amplitudes_[i] * 1e10));
     }
     v.push_back(std::log(amplitudes_[amplitudes_.size() - 1] * 1e10));
 }
Exemple #24
0
CCArray *Astar::findPath(int curX, int curY, int aimX, int aimY, CCTMXTiledMap* passmap)
{
    //参数以及记录路径数组初始化
	curCol = curX;
    curRow = curY;
	aimCol = aimX;
	aimRow = aimY;
	map = passmap;
	path = new CCArray();
	open = new CCArray();
    AstarItem * temp = new AstarItem();
	open->addObject(temp);
	AstarItem * temp1 = new AstarItem();
	temp1->setpos(curCol,curRow);
	temp1->setg(0);
	int ag = getH(curCol,curRow);
	temp1->seth(ag);
	temp1->setfid(0);
	temp1->setf(ag);
	open->addObject(temp1);
	close = new CCArray();
    //遍历寻找路径
	while(open->count() > 1){
	   fromopentoclose();//open和close列表管理
	   int fatherid = close->count() - 1;
	   if(abs(aimCol - ((AstarItem *)close->objectAtIndex(fatherid))->getcol()) <= 1 && abs(aimRow - ((AstarItem *)close->objectAtIndex(fatherid))->getrow()) <= 1){
		   getpath();
		   break;
	   }else{
           //搜索
	       starseach(fatherid);
	   }
	}
	open->removeAllObjects();
	close->removeAllObjects();
    //获得路径
	if(path->count() == 0){
	   return NULL;
	}else{
		if(((AstarItem *)path->lastObject())->getcol() != aimCol || ((AstarItem *)path->lastObject())->getrow() != aimRow){
		   AstarItem * temp = new AstarItem();
	       temp->setpos(aimCol,aimRow);
		   path->addObject(temp);
		}
		return path;
	}
}
Exemple #25
0
//==============================================================================
//                     CALC BODY ACCELERATIONS FROM UDOT
//==============================================================================
// This method calculates:
//      A_GB = J*udot + Jdot*u
// in O(N) time, where udot is supplied as an argument and Jdot*u is the 
// coriolis acceleration which we get from the velocity cache. This also serves
// as pass 1 for inverse dynamics.
//
// This must be called base to tip. The cost is 12*dof + 18 flops.
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void 
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::
calcBodyAccelerationsFromUdotOutward(
    const SBTreePositionCache&  pc,
    const SBTreeVelocityCache&  vc,
    const Real*                 allUDot,
    SpatialVec*                 allA_GB) const
{
    const Vec<dof>& udot = fromU(allUDot);
    SpatialVec&     A_GB = allA_GB[nodeNum];

    // Shift parent's A_GB outward. (Ground A_GB is zero.) 12 flops.
    const SpatialVec A_GP = ~getPhi(pc) * allA_GB[parent->getNodeNum()];

    // 12*dof+6 flops.
    A_GB = A_GP + getH(pc)*udot + getMobilizerCoriolisAcceleration(vc); 
}
Exemple #26
0
//==============================================================================
//                                   CALC UDOT
//==============================================================================
// To be called from tip to base.
// Temps do not need to be initialized.
//
// First pass
// ----------
// Given previously-calculated quantities from the State 
//      P       this body's articulated body inertia
//     Phi      composite body child-to-parent shift matrix
//      H       joint transition matrix; sense is transposed from Jain
//      G       P * H * DI
// and supplied arguments
//      F       body force applied to B
//      f       generalize forces applied to B's mobilities
//    udot_p    known udots (if mobilizer is prescribed)
// calculate 
//      z       articulated body residual force on B
//    zPlus     AB residual force as felt on inboard side of mobilizer
//     eps      f - ~H*z  gen force plus gen equiv of body forces
// For a prescribed mobilizer we have zPlus=z. Otherwise, zPlus = z + G*eps.
//
// This is the first (inward) loop of Algorithm 16.2 on page 323 of Jain's
// 2011 book, modified to include the applied body force and not including
// the auxiliary quantity "nu=DI*eps".
template<int dof, bool noR_FM, bool noX_MB, bool noR_PF> void
RigidBodyNodeSpec<dof, noR_FM, noX_MB, noR_PF>::calcUDotPass1Inward(
    const SBInstanceCache&                  ic,
    const SBTreePositionCache&              pc,
    const SBArticulatedBodyInertiaCache&    abc,
    const SBDynamicsCache&                  dc,
    const Real*                             jointForces,
    const SpatialVec*                       bodyForces,
    const Real*                             allUDot,
    SpatialVec*                             allZ,
    SpatialVec*                             allZPlus,
    Real*                                   allEpsilon) const 
{
    const Vec<dof>&   f     = fromU(jointForces);
    const SpatialVec& F     = bodyForces[nodeNum];
    SpatialVec&       z     = allZ[nodeNum];
    SpatialVec&       zPlus = allZPlus[nodeNum];
    Vec<dof>&         eps   = toU(allEpsilon);

    const bool isPrescribed = isUDotKnown(ic);
    const HType&              H = getH(pc);
    const ArticulatedInertia& P = getP(abc);
    const HType&              G = getG(abc);

    // z = Pa+b - F
    z = getMobilizerCentrifugalForces(dc) - F; // 6 flops

    // z += P H udot_p if prescribed
    if (isPrescribed && !isUDotKnownToBeZero(ic)) {
        const Vec<dof>& udot = fromU(allUDot);
        z += P*(H*udot); // 66+12*dof flops
    }

    // z += sum(Phi(child) * zPlus(child)) for all children
    for (unsigned i=0; i<children.size(); ++i) {
        const PhiMatrix&  phiChild   = children[i]->getPhi(pc);
        const SpatialVec& zPlusChild = allZPlus[children[i]->getNodeNum()];
        z += phiChild * zPlusChild; // 18 flops
    }

    eps  = f - ~H*z; // 12*dof flops

    zPlus = z;
    if (!isPrescribed)
        zPlus += G*eps; // 12*dof flops
}
void CSulGuiRadioButton::init()
{
	CSulGuiCanvas::init();

	sigma::VEC_VEC3::vector	vecPos;
	sigma::VEC_VEC3::vector	vecPosDots;
	
	float w = getW();
	float h = getH();

	double r = m_radioSizeOuter;
	double rdot = m_radioSizeInner;

	for ( int i=0; i<17; i++ )
	{
		double d = ((2.0*osg::PI)/16.0) * (double)i;

		double x = cos( d );
		double y = sin( d );

		osg::Vec3 pos = osg::Vec3( x*r+r, y*r+h/2.0f, 0 );
		vecPos.push_back( pos );

		osg::Vec3 posDot = osg::Vec3( x*rdot+r, y*rdot+h/2.0f, 0 );
		vecPosDots.push_back( posDot );
	}

	// outer circle
	CSulGeodeLineStrip* pLineStrip = new CSulGeodeLineStrip( vecPos );	
	pLineStrip->setWidth( 2.0f );
	addChild( pLineStrip );

	// text
	CSulGuiText* pGuiText = new CSulGuiText( m_sText, r*2.0f+m_paddingText, h/2.0f, m_fontSize );
	pGuiText->init();
	pGuiText->getTextObject()->setAlignment( osgText::TextBase::LEFT_CENTER );
	addChild( pGuiText );

	// inner dot
	m_rTriangleFan = new CSulGeomTriangleFan( vecPosDots );
	addChild( m_rTriangleFan );

	showCanvas( false );
}
Exemple #28
0
void GLPresenter::initGL()
{
	glDisable(GL_LIGHTING);
	glDisable(GL_DEPTH_TEST);
	glEnable(GL_TEXTURE_2D);

	glViewport(0, 0, getW(), getH());

	glGenTextures(1, &texId);
	glBindTexture(GL_TEXTURE_2D, texId);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

	GLubyte* data = (GLubyte*)new GLubyte[data_size];
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, reqW/2, reqH, 0, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)data);
	delete data;
}
Exemple #29
0
bool Astar::checkOpen(int col, int row, int id)
{
    // 检查open列表中是否有更小的步长,并排序
    for(int i = _open->count() - 1; i > 0; i--) {
        auto item = (AstarItem*)_open->getObjectAtIndex(i);
        if(item->getCol() == col && item->getRow() == row) {
            int tempG = getG(col, row, id);
            if(tempG < item->getG()) {
                item->setG(tempG);
                item->setFid(id);
                item->setF(tempG + item->getH());
                resetSort(i);
            }
            return false;
        }
    }

    return true;
}
Exemple #30
0
bool AstarFlexible::checkNearby()
{
	int i=0,j=0,x=0,y=0,k=0,g=0,h=0;
	
	AstarNode* searchedNode;
	
	for(;k<DEFAULT_NEARS_LENGTH;k++){
		//near=defaultNears[k];
		i=defaultNears[k][0];
		j=defaultNears[k][1];
		
		x=m_current->getX()+i;
		y=m_current->getY()+j;
		
		//结束提前,可对目标是障碍物进行寻路。(例:人物要对某个建筑进行操作,比如攻击,要走到建筑旁边才可以)
		if (isEnd(x,y ,i ,j)) {//如果是斜着寻路,则要对旁边是否有障碍物进行判断。
			return true;//查找成功
		}
		
		if(!isOut(x,y) && isWorkableWithCrossSide(x ,y ,i ,j)){
			if(!isInClose(x ,y)){
				g=m_current->getG()+(i==0||j==0?ASTAR_G_LINE:ASTAR_G_CROSS);
				searchedNode=getFromOpen(x ,y);
				if(searchedNode!=NULL){
					//在开起列表中,比较G值
					if (g < searchedNode->getG()) {
						//有最小F值,重新排序
						setOpenSeqNode(searchedNode,g);
					}
				}else {
					//没有搜索过,直接添加到开起列表中
					h=getH(x ,y);
					AstarNode* astarNode=new AstarNode();
					astarNode->init(x ,y,g,h);
					astarNode->setParent(m_current);
					addToOpen(astarNode);
					astarNode->release();
				}
			}
		}
	}
	return false;
}