//-----------------------------------------------------------------------
		// Return the ceiling of the passed in coord based on valid LOD.
		int Ceil( int localPageCoord ) const
		{
			if( Floor( localPageCoord ) == localPageCoord )
				return localPageCoord;	// Already at ceiling.
			else
				return Floor( localPageCoord + lodStep_ );
        }
Beispiel #2
0
int CTimer::StartTimer(double first, double interval){
	if(m_timer == 0){
		NLOG_ERROR("Timer Not Tnitialized!");
		return -1;
	}

	//first == 0
	if(fabs(first) < 0.000000001){
		NLOG_ERROR("arg first [%lf] Is Invalid!", first);
		return -1;
	}
	//interval == 0
	if(fabs(interval) < 0.000000001){
		NLOG_ERROR("arg interval [%lf] Is Invalid!", interval);
		return -1;
	}

	m_first = first;
	m_interval = interval;
	
	 struct  itimerspec timespec;
	 memset(&timespec, 0, sizeof(timespec));
	 timespec.it_value.tv_sec = Floor(first);
	 timespec.it_value.tv_nsec = ToNanoseconds(Frac(first));
	 timespec.it_interval.tv_sec = Floor(interval);
	 timespec.it_interval.tv_nsec =ToNanoseconds(Frac(interval));
	/* NLOG_DEBUG("Timer(%s) Start! First Run[%.6lf], Interval[%.6lf]",
					m_name,first, interval);
	*/
	return timer_settime(m_timer, 0, &timespec, NULL);		 
}
Beispiel #3
0
void Serial_Parse(void)
{
   	// Local variables for assigning the bytes too
	unsigned int node;
	unsigned int sub_comp;
	unsigned int instruction;
	
	// Grab the three bytes and sort according to their representation
	node = Serial_Recieve[0] - 48;
	sub_comp = Serial_Recieve[1] - 48;
	instruction = Serial_Recieve[2] - 48;
	
	switch (node)
	{
		// Elevator Car
		case CAR:
			Car(sub_comp, instruction);
			break;
		// Floor 1
		case F1:
			Floor(F1, sub_comp, instruction);
			break;
		// Floor 2
		case F2:
		    Floor(F2, sub_comp, instruction);
			break;
		// Floor 3
		case F3:
		    Floor(F3, sub_comp, instruction);
			break;
		default:
			    msDELAY(100);
			    break;
	}
}
Beispiel #4
0
// GridDensityMedium Method Definitions
Float GridDensityMedium::Density(const Point3f &p) const {
    // Compute voxel coordinates and offsets for _p_
    Point3f pSamples(p.x * nx - .5f, p.y * ny - .5f, p.z * nz - .5f);
    Point3i pi = (Point3i)Floor(pSamples);
    Vector3f d = pSamples - Floor(pSamples);

    // Trilinearly interpolate density values to compute local density
    Float d00 = Lerp(d.x, D(pi), D(pi + Vector3i(1, 0, 0)));
    Float d10 = Lerp(d.x, D(pi + Vector3i(0, 1, 0)), D(pi + Vector3i(1, 1, 0)));
    Float d01 = Lerp(d.x, D(pi + Vector3i(0, 0, 1)), D(pi + Vector3i(1, 0, 1)));
    Float d11 = Lerp(d.x, D(pi + Vector3i(0, 1, 1)), D(pi + Vector3i(1, 1, 1)));
    Float d0 = Lerp(d.y, d00, d10);
    Float d1 = Lerp(d.y, d01, d11);
    return Lerp(d.z, d0, d1);
}
Beispiel #5
0
void FinalDestination::Initialize() {
	name = "finaldestination";
	width = 512;
	height = 256;
	topdeath = -320;
	leftdeath = -192;
	rightdeath = 704;
	bottomdeath = 256;
	minhorizscroll = -128;
	maxhorizscroll = 384;
	minvertscroll = -192;
	maxvertscroll = 64;
	spawnx.push_back(160);
	spawnx.push_back(288);
	spawnx.push_back(96);
	spawnx.push_back(352);
	spawny.push_back(4);
	spawny.push_back(4);
	spawny.push_back(4);
	spawny.push_back(4);
	floors.push_back(Floor(64, 132, 384, 0, false));
	walls.push_back(Wall(96, 132, 116, "left"));
	walls.push_back(Wall(416, 132, 116, "right"));
	walls.push_back(Wall(65, 132, 1, "left"));
	walls.push_back(Wall(447, 132, 1, "right"));
	ceilings.push_back(Ceiling(64, 132, 384));
	ledges.push_back(Ledge(64, 132, "left"));
	ledges.push_back(Ledge(448, 132, "right"));
	songnames.push_back("Final Destination");
	songnames.push_back("Final Destination");
	songartists.push_back("Super Smash Bros. Brawl");
	songartists.push_back("Super Smash Bros. Melee");
	songs.push_back("SSBDS_Files/music/stages/finaldestination1.mp3");
	songs.push_back("SSBDS_Files/music/stages/finaldestination2.mp3");
} // initializes all the variables for final destination
Beispiel #6
0
Bounds2i Film::GetSampleBounds() const {
    Bounds2f floatBounds(Floor(Point2f(croppedPixelBounds.pMin) +
                               Vector2f(0.5f, 0.5f) - filter->radius),
                         Ceil(Point2f(croppedPixelBounds.pMax) -
                              Vector2f(0.5f, 0.5f) + filter->radius));
    return (Bounds2i)floatBounds;
}
Beispiel #7
0
main()
    {
    struct BST *rt=NULL;
    
        rt=insert(rt,5);
        insert(rt,64);
        insert(rt,23);
        insert(rt,2);
        insert(rt,3);
        insert(rt,4);
        
        int i=0;
        printf("INPUT\tFLOOR\tCEIL\n");
        for(i=0;i<=34;i++)
            {
                int c=Ceil(rt,i);
                int f=Floor(rt,i);
                 printf(" [%d]\t[%d]\t[%d]\n",i,f,c);   
            
            }
        
    
    printf("\nInoredr:\n");
    printinorder(rt);
    int sum=0;
    addsum(rt,&sum);
    printf("\nInoredr:\n");
    printinorder(rt);
    printf("\n");
    }
MapManager DungeonGenerator::Generate(const DungeonSize& sizeData, const DungeonData& dungeonData)
{
	MapManager manager;
	for (size_t i = 0; i < sizeData.DungeonHeight(); ++i)
	{
		for (size_t j = 0; j < sizeData.DungeonWidth(); ++j)
		{
			if (dungeonData.IsThis(ObjTypeOnMap::WALL, i, j))
			{
				auto wall = std::make_shared<Wall>(Wall(Vector2(j*GeneralConstant::img_size_width, i*GeneralConstant::img_size_height)));
				manager.Add(wall);
				continue;
			}
			if (dungeonData.IsThis(ObjTypeOnMap::FLOOR, i, j))
			{
				auto floor = std::make_shared<Floor>(Floor(Vector2(j*GeneralConstant::img_size_width, i*GeneralConstant::img_size_height)));
				manager.Add(floor);
				continue;
			}
			if (dungeonData.IsThis(ObjTypeOnMap::PATH, i, j))
			{
				auto path = std::make_shared<Path>(Path(Vector2(j*GeneralConstant::img_size_width, i*GeneralConstant::img_size_height)));
				manager.Add(path);
				continue;
			}
		}
	}

	return  manager;
}
void __fastcall TAcquireThread::Draw() {
	switch(mm) {
	case 0:
//		StatusRecForm->Label1->Caption = s;
//		StatusRecForm->Label2->Caption = s1;
		break;
	case 1:
		StatusRecForm->Close();
		MainForm->StartMonitoring();
		break;
	case 2:
//		StatusRecForm->Label2->Caption = "Количество блоков " + IntToStr
//			(num_blocks);
		break;
	case 3:
//		StatusRecForm->ProgressBar1->Position = pos;
		break;
	case 4:
		TFormatSettings FormatSettings;
		GetLocaleFormatSettings(GetSystemDefaultLCID(), FormatSettings);
		FormatSettings.ThousandSeparator = 160;
		FormatSettings.CurrencyString = "";
		FormatSettings.CurrencyDecimals = 0;

		MainForm->ListView2->Items->Item[0]->SubItems[0].Text = FloatToStr(t)
			+ " нс";
		MainForm->ListView2->Items->Item[1]->SubItems[0].Text = FloatToStrF
			(AcfParams._time * 1e-6, ffFixed, 5, 2) + " с";
		MainForm->ListView2->Items->Item[2]->SubItems[0].Text = Format
			("%m", ARRAYOFCONST((double(AcfParams.vybr))), FormatSettings);
		MainForm->ListView2->Items->Item[3]->SubItems[0].Text = FloatToStr
			(AcfParams.zashk / n0 * 100) + "%";
		MainForm->ListView2->Items->Item[4]->SubItems[0].Text = Format
			("%m", ARRAYOFCONST((1e6 * n1 / AcfParams._time)), FormatSettings);
		MainForm->ListView2->Items->Item[5]->SubItems[0].Text = Format
			("%m", ARRAYOFCONST((double(n1))), FormatSettings);

		int ind = 0;
		for (int i = 0; i < n1; i++) {
			if (RawData_t.a[i] > 1e6) {
				ind = i - 1;
				break;
			}
		}

		int m = Floor(ind / 1e3);
		MainForm->Series1->Clear();
		for (int i = 0; i < 1e3; i++) {
			if (!(RawData.a[i * m] == 0)) {
				MainForm->Series1->AddXY(RawData_t.a[i * m] * 1e-6, 1e9 /
					(RawData.a[i * m] * t));
			}
			else {
				MainForm->Series1->AddNullXY(RawData_t.a[i * m] * 1e-6, 0);
			}
		}
		break;
	}

}
Beispiel #10
0
 /**
  * Add integer \e k to the RandomNumber.
  *
  * @param[in] k the integer to add.
  **********************************************************************/
 void AddInteger(int k) throw() {
   k += Floor();             // The new floor
   int ns = k < 0 ? -1 : 1;  // The new sign
   if (ns != _s)             // If sign changes, set f = 1 - f
     for (size_t k = 0; k < Size(); ++k)
       _f[k] = ~_f[k] & mask;
   _n = ns > 0 ? k : -(k + 1);
 }
Beispiel #11
0
int Floor(struct BST *root,int input)
    {
        if(!root)
            return -1;
            
            if(root->data==input)
                return root->data;
                
             if(root->data>input)
                return Floor(root->l,input);
                
             int f=Floor(root->r,input);
             return f>=input?f:root->data;      
    
    
    
    }   
Beispiel #12
0
void Corneria::Initialize() {
	name = "corneria";
	width = 512;
	height = 256;
	topdeath = -320;
	bottomdeath = 256;
	leftdeath = -192;
	rightdeath = 704;
	minhorizscroll = -128;
	maxhorizscroll = 384;
	minvertscroll = -192;
	maxvertscroll = 64;
	spawnx.push_back(160);
	spawnx.push_back(288);
	spawnx.push_back(96);
	spawnx.push_back(224);
	spawny.push_back(-128);
	spawny.push_back(-128);
	spawny.push_back(-128);
	spawny.push_back(-128);
	floors.push_back(Floor(-14, 29, 64, 16, false));
	floors[0].rightneighbor = 1;
	floors.push_back(Floor(50, 13, 146, -12, false));
	floors[1].leftneighbor = 0;
	floors[1].rightneighbor = 2;
	floors.push_back(Floor(196, 25, 66, 10, false));
	floors[2].leftneighbor = 1;
	floors[2].rightneighbor = 3;
	floors.push_back(Floor(262, 15, 37, 31, false));
	floors[3].leftneighbor = 2;
	floors[3].rightneighbor = 4;
	floors.push_back(Floor(299, -16, 91, 31, false));
	floors[4].leftneighbor = 3;
	floors.push_back(Floor(384, 46, 55, 0, false));
	floors[5].rightneighbor = 6;
	floors.push_back(Floor(439, 46, 38, 8, false));
	floors[6].leftneighbor = 5;
	floors[6].rightneighbor = 7;
	floors.push_back(Floor(477, 38, 54, -23, false));
	floors[7].leftneighbor = 6;
	floors.push_back(Floor(78, 104, 35, 0, false));
	ledges.push_back(Ledge(-14, 29, "left"));
	ledges.push_back(Ledge(390, -47, "right"));
	ledges.push_back(Ledge(531, 61, "right"));
	songnames.push_back("Main Theme");
	songnames.push_back("Fortuna");
	songartists.push_back("Star Fox");
	songartists.push_back("Star Fox Assault");
	songs.push_back("SSBDS_Files/music/stages/corneria1.mp3");
	songs.push_back("SSBDS_Files/music/stages/corneria2.mp3");
} // initializes Corneria
Beispiel #13
0
Floor Projectile::checkFloorCollision(int deltax, int deltay) {
	for(int n = 0; n < (int)((mystage -> getFloors()).size()); n++) {
		if(y+deltay <= mystage -> getFloors()[n].y && y+deltay+dy > mystage -> getFloors()[n].y && x+deltax+dx > mystage -> getFloors()[n].x && x+deltax+dx < mystage -> getFloors()[n].x + mystage -> getFloors()[n].length) {
			return mystage -> getFloors()[n];
		}
	}
	return Floor(0, 0, 0, 0, false);
}
Beispiel #14
0
static long Mod (long value, long base)
{
	if (base <= 0)
	{
		return 0;
	}

	return value - base * Floor (value, base);
}
Beispiel #15
0
void CastleSiege::Initialize() {
	name = "castlesiege";
	width = 512;
	height = 384;
	topdeath = -320;
	bottomdeath = 384;
	leftdeath = -128;
	rightdeath = 576;
	minhorizscroll = -64;
	maxhorizscroll = 256;
	minvertscroll = -192;
	maxvertscroll = 64;
	spawnx.push_back(160);
	spawnx.push_back(288);
	spawnx.push_back(96);
	spawnx.push_back(352);
	spawny.push_back(88);
	spawny.push_back(88);
	spawny.push_back(88);
	spawny.push_back(88);
	floors.push_back(Floor(40, 216, 161, 0, false));
	floors.push_back(Floor(202, 216, 98, 25, false));
	floors[0].rightneighbor = 1;
	floors[1].leftneighbor = 0;
	floors[1].rightneighbor = 2;
	floors.push_back(Floor(300, 191, 150, 0, false));
	floors[2].leftneighbor = 1;
	floors.push_back(Floor(84, 160, 110, 0, true));
	floors.push_back(Floor(302, 142, 104, 0, true));
	ledges.push_back(Ledge(40, 216, "left"));
	ledges.push_back(Ledge(450, 191, "right"));
	walls.push_back(Wall(41, 216, 40, "left"));
	walls.push_back(Wall(449, 191, 40, "right"));
	ceilings.push_back(Ceiling(40, 256, 100));
	ceilings.push_back(Ceiling(349, 231, 100));
	walls.push_back(Wall(55, 256, 200, "left"));
	walls.push_back(Wall(435, 231, 200, "right"));
	songnames.push_back("Ike's Theme");
	songnames.push_back("Victory is Near");
	songartists.push_back("Fire Emblem 10: Radiant Dawn");
	songartists.push_back("Fire Emblem 9: Path of Radiance");
	songs.push_back("SSBDS_Files/music/stages/castlesiege1.mp3");
	songs.push_back("SSBDS_Files/music/stages/castlesiege2.mp3");
} // initializes Castle Siege
void EC_MeshmoonWater::OnUpdate(float elapsedTime)
{
#ifdef MESHMOON_TRITON
    if (!visible.Get() || !ParentScene() || !state_.environment || !state_.ocean)
        return;

    PROFILE(EC_MeshmoonWater_Update);

    if (!windConditionsComp_.expired())
    {
        if (windConditionsComp_.lock().get()->TypeId() == EC_MeshmoonSky::TypeIdStatic())
        {
            EC_MeshmoonSky *meshmoonSky = dynamic_cast<EC_MeshmoonSky*>(windConditionsComp_.lock().get());
            if (meshmoonSky)
            {
                float windDirFloored = Floor(fmod(meshmoonSky->windDirection.Get() + 180.0f, 360.0f));
                float windSpeedFloored = Floor(meshmoonSky->windSpeed.Get());
                if (windSpeedFloored != state_.windSpeedPerSec || windDirFloored != Floor(state_.windDirDegrees))
                {
                    state_.windDirDegrees = windDirFloored;
                    state_.windSpeedPerSec = windSpeedFloored;
                    UpdateWeatherConditions();
                }
            }
        }
        else if (windConditionsComp_.lock().get()->TypeId() == EC_SkyX::TypeIdStatic())
        {
            EC_SkyX *skyx = dynamic_cast<EC_SkyX*>(windConditionsComp_.lock().get());
            if (skyx)
            {
                /// SkyX-To-Triton wind direction needs a small adjustment for them to align properly.
                /// (-skyxDir + 90 deg) and we round the float + modulo with 360 degrees to get [0,359] range.
                float tritonWindDir = fmod(Floor(-skyx->windDirection.Get() + 90.0f), 360.0f);
                if (skyx->windSpeed.Get() != state_.windSpeedPerSec || tritonWindDir != Floor(state_.windDirDegrees))
                {
                    state_.windDirDegrees = tritonWindDir;
                    state_.windSpeedPerSec = skyx->windSpeed.Get();
                    UpdateWeatherConditions();
                }
            }
        }
    }
#endif
}
Beispiel #17
0
/*
!!!! This function is designed for the controller !!!!!

Purpose: Parse the message into each of the components and then distrubute the commands as nessesary
  Input: Recieve Queue
 Output: none
*/
void Parse_Data(void)
{
	// Local variables for assigning the bytes too
	unsigned char node;
	unsigned char sub_comp;
	unsigned char instruction;
	
	// Grab the three bytes and sort according to their representation
	node = rxdata[0];
	sub_comp = rxdata[1];
	instruction = rxdata[2];
	
	SCIprintf("%d%d%d", rxdata[0], rxdata[1], rxdata[2]);
	
	//putsSCI(rxdata);
	
	switch (node)
	{
	    case PID:
	        Feedback(sub_comp, instruction);
	        break;
		// Elevator Car
		case CAR:
			Car(sub_comp, instruction);
			break;
		// Floor 1
		case F1:
			Floor(F1, sub_comp, instruction);
			break;
		// Floor 2
		case F2:
		    Floor(F2, sub_comp, instruction);
			break;
		// Floor 3
		case F3:
		    Floor(F3, sub_comp, instruction);
			break;
		default:
			    msDELAY(100);
			    break;
	}
}
Beispiel #18
0
struct BT  *Floor(struct BT *root, int key, struct BT **prev)
{
	
	if(root)
	{
		if(!Floor(root->l, key, prev))
			return 0;
		
		if(root->data==key)
				return root;
	 if(root->data>key )
				return (*prev);
		
			*prev = root;
		return Floor(root->r, key, prev);
		
		
	}else
	return NULL;
}
Beispiel #19
0
std::unique_ptr<FilmTile> Film::GetFilmTile(const Bounds2i &sampleBounds) {
    // Bound image pixels that samples in _sampleBounds_ contribute to
    Vector2f halfPixel = Vector2f(0.5f, 0.5f);
    Bounds2f floatBounds = (Bounds2f)sampleBounds;
    Point2i p0 = (Point2i)Ceil(floatBounds.pMin - halfPixel - filter->radius);
    Point2i p1 = (Point2i)Floor(floatBounds.pMax - halfPixel + filter->radius) +
                 Point2i(1, 1);
    Bounds2i tilePixelBounds = Intersect(Bounds2i(p0, p1), croppedPixelBounds);
    return std::unique_ptr<FilmTile>(new FilmTile(
        tilePixelBounds, filter->radius, filterTable, filterTableWidth));
}
Beispiel #20
0
const float Math::Sin(const float t)
{
    float B = 1.27323954474f;
    float C = -0.40528473456f;
    float P = 0.225f;
    float sign = t < 0 ? -1.0f : 1.0f;
    float x = t - Floor((t + PI * sign) / PI2) * PI2;
    float y = B * x + C * x * Abs(x);
    y = P * (y * Abs(y) - y) + y;
    return sinf(t);
}
/*virtual*/ void UIWidgetText::Tick( const float DeltaTime )
{
	XTRACE_FUNCTION;

	if( !m_Velocity.IsZero() )
	{
		m_TopLeft += m_Velocity * DeltaTime;

		if( m_ClampToPixelGrid )
		{
			// Floor instead of round so we don't mess with the velocity.
			// (Essentially the same as subtracting the half pixel offset
			// before rounding, since it just adds 0.5.)
			const float PixelGridOffset = 0.5f - GetPixelGridOffset();
			m_TopLeft.x = Floor( m_TopLeft.x ) + PixelGridOffset;
			m_TopLeft.y = Floor( m_TopLeft.y ) + PixelGridOffset;
		}

		UpdateRenderPosition();
	}
}
Beispiel #22
0
int MilestonePath::Eval(Real t, Config& c) const
{
  if(t <= Zero) { c = edges.front()->Start(); return 0; }
  else if(t >= One) { c = edges.back()->Goal(); return edges.size()-1; }
  else {
    Real u=t*(Real)edges.size();
    Real u0=Floor(u);
    int index = (int)u0;
    Assert(index >= 0 && index < (int)edges.size());
    edges[index]->Eval(u-u0,c);
    return index;
  }
}
Beispiel #23
0
static void FillRightOrientedTriangle (HDC hDc)
{
	long y          = points [LOW_POINT].y;

	long leftEdge   = points [LOW_POINT].x;
	long rightEdge  = points [LOW_POINT].x;

	long leftDx     = longEdge->dx;
	long leftDy     = longEdge->dy;
	long rightDx;
	long rightDy;

	long leftConst  = Floor (longEdge->dx, longEdge->dy);
	long rightConst;

	long leftMod    = Mod (longEdge->dx, longEdge->dy);
	long rightMod;

	long leftNumer  = -1;
	long rightNumer = -1;

	rightConst = Floor (lowEdge->dx, lowEdge->dy);
	rightDx    = lowEdge->dx;
	rightDy    = lowEdge->dy;
	rightMod   = Mod (rightDx, rightDy);

	while (lowEdge->dy--)
	{
		WriteRow (hDc, leftEdge, rightEdge, y++);

		leftEdge    += leftConst  + Floor (Mod (leftNumer,  leftDy)  + leftMod,  leftDy);
		rightEdge   += rightConst + Floor (Mod (rightNumer, rightDy) + rightMod, rightDy);
		
		leftNumer   += leftDx;
		rightNumer	+= rightDx;
	}

	rightConst = Floor (topEdge->dx, topEdge->dy);
	rightDx    = topEdge->dx;
	rightDy    = topEdge->dy;
	rightMod   = Mod (rightDx, rightDy);

	while (topEdge->dy--)
	{
		WriteRow (hDc, leftEdge, rightEdge, y++);

		leftEdge    += leftConst  + Floor (Mod (leftNumer,  leftDy)  + leftMod,  leftDy);
		rightEdge   += rightConst + Floor (Mod (rightNumer, rightDy) + rightMod, rightDy);  

		leftNumer   += leftDx;
		rightNumer	+= rightDx;

	}
}
Beispiel #24
0
void PokemonStadium::Initialize() {
	name = "pokemonstadium";
	width = 512;
	height = 256;
	topdeath = -320;
	bottomdeath = 256;
	leftdeath = -192;
	rightdeath = 704;
	minhorizscroll = -128;
	maxhorizscroll = 384;
	minvertscroll = -192;
	maxvertscroll = 64;
	spawnx.push_back(160);
	spawnx.push_back(288);
	spawnx.push_back(96);
	spawnx.push_back(352);
	spawny.push_back(26);
	spawny.push_back(26);
	spawny.push_back(26);
	spawny.push_back(26);
	floors.push_back(Floor(42, 154, 428, 0, false));
	floors.push_back(Floor(128, 110, 62, 0, true));
	floors.push_back(Floor(324, 110, 62, 0, true));
	walls.push_back(Wall(43, 154, 102, "left"));
	walls.push_back(Wall(469, 154, 102, "right"));
	ceilings.push_back(Ceiling(42, 216, 428));
	ledges.push_back(Ledge(42, 154, "left"));
	ledges.push_back(Ledge(470, 154, "right"));
	songnames.push_back("Pokemon Gym / Evolution");
	songnames.push_back("Battle Theme");
	songnames.push_back("Lugia's Song");
	songartists.push_back("Pokemon Red/Blue/Yellow");
	songartists.push_back("Pokemon Gold/Silver/Crystal");
	songartists.push_back("Pokemon 2000");
	songs.push_back("SSBDS_Files/music/stages/pokemonstadium1.mp3");
	songs.push_back("SSBDS_Files/music/stages/pokemonstadium2.mp3");
	songs.push_back("SSBDS_Files/music/stages/pokemonstadium3.mp3");
} // initializes the pokemon stadium stage
Beispiel #25
0
Building::Building(const FloorNumber bottomFloor,
                   const FloorNumber topFloor,
                   const unsigned int numElevators,
                   const Elevator& elevator) :
      mBottomFloor(bottomFloor),
      mTopFloor(topFloor),
      mElevators(numElevators, elevator)
{
   assert(mTopFloor > mBottomFloor);
   for (FloorNumber i = bottomFloor; i <= topFloor; ++i)
   {
      mFloors.emplace(i, Floor());
   }
}
Beispiel #26
0
void ViewResource::RenderLinearPath(const LinearPathResource* rc,Real pathTime)
{
  if(pathViewer.robot==NULL) {
    printf("ViewResource: Robot is NULL\n");
    return;
  }
  Config oldq = pathViewer.robot->q;
  if(rc->times.empty()) {
  }
  else if(rc->times.front() == rc->times.back()) {
    pathViewer.robot->UpdateConfig(rc->milestones[0]);
    pathViewer.Draw();
  }
  else {
    //TODO: faster tracking using upper_bound?
    Assert(rc->times.size()==rc->milestones.size());
    Assert(rc->times.back() > rc->times.front());
    Real normalizedPathTime = pathTime;
    //looping behavior
    /*
      while(normalizedPathTime < rc->times.front()) 
      normalizedPathTime += rc->times.back()-rc->times.front();
      while(normalizedPathTime > rc->times.back()) 
      normalizedPathTime -= rc->times.back()-rc->times.front();
      pathTime = normalizedPathTime;
    */
    //bouncing behavior
    double cnt = (pathTime-rc->times.front())/(rc->times.back()-rc->times.front());
    int n = (int)Floor(cnt);
    if(n%2==0)
      normalizedPathTime = (cnt-n)*(rc->times.back()-rc->times.front());
    else
      normalizedPathTime = rc->times.back()-(cnt-n)*(rc->times.back()-rc->times.front());
    bool drawn=false;
    for(size_t i=0;i+1<rc->times.size();i++) {
      Assert(rc->milestones[i].n == oldq.n);
      Assert(rc->milestones[i+1].n == oldq.n);
      if(rc->times[i] <= normalizedPathTime && normalizedPathTime <= rc->times[i+1]) {
	Real u=(normalizedPathTime-rc->times[i])/(rc->times[i+1]-rc->times[i]);
	Vector q;
	Interpolate(*pathViewer.robot,rc->milestones[i],rc->milestones[i+1],u,q);
	pathViewer.robot->UpdateConfig(q);
	pathViewer.Draw();
	drawn=true;
	break;
      }
    }
  }
  pathViewer.robot->UpdateConfig(oldq);
}
void RHybridHeap::Walk(SWalkInfo* aInfo, TAny* aBfr, TInt aLth, TCellType aBfrType, TAllocatorType aAllocatorType)
{
    //
    // This function is always called from RHybridHeap::GetInfo.
    // Actual walk function is called if SWalkInfo pointer is defined
    // 
    //
    if ( aInfo )
        {
#ifdef __KERNEL_MODE__
		(void)aAllocatorType;
#if defined(_DEBUG)		
		if ( aBfrType == EGoodAllocatedCell )
			aInfo->iFunction(aInfo->iParam, aBfrType, ((TUint8*)aBfr+EDebugHdrSize), (aLth-EDebugHdrSize) );
		else
			aInfo->iFunction(aInfo->iParam, aBfrType,  aBfr, aLth );
#else
		aInfo->iFunction(aInfo->iParam, aBfrType, aBfr, aLth );
#endif
		
#else  // __KERNEL_MODE__
		
        if ( aAllocatorType & (EFullSlab + EPartialFullSlab + EEmptySlab + ESlabSpare) )
			{
			if ( aInfo->iHeap )
				{
				TUint32 dummy;
				TInt    npages;
				aInfo->iHeap->DoCheckSlab((slab*)aBfr, aAllocatorType);
				__HEAP_CORRUPTED_TEST_STATIC(aInfo->iHeap->CheckBitmap(Floor(aBfr, PAGESIZE), PAGESIZE, dummy, npages),
											 aInfo->iHeap, ETHeapBadCellAddress, aBfr, aLth);
				}
			if ( aAllocatorType & EPartialFullSlab )
				 WalkPartialFullSlab(aInfo, (slab*)aBfr, aBfrType, aLth);	
            else if ( aAllocatorType & EFullSlab )
					WalkFullSlab(aInfo, (slab*)aBfr, aBfrType, aLth);
			}
#if defined(_DEBUG)     
        else  if ( aBfrType == EGoodAllocatedCell )
            aInfo->iFunction(aInfo->iParam, aBfrType, ((TUint8*)aBfr+EDebugHdrSize), (aLth-EDebugHdrSize) );
        else
            aInfo->iFunction(aInfo->iParam, aBfrType,  aBfr, aLth );
#else
        else
            aInfo->iFunction(aInfo->iParam, aBfrType, aBfr, aLth );
#endif

#endif // __KERNEL_MODE	
        }
Beispiel #28
0
void Cos::CalcOneStep(){
    _pos += _inc;
    if(_pos >= _N){
        _pos -= _N;
    }
    
    int i = Floor(_pos);
    double frac = _pos-i;
    
    int ii = i+1;
    if(ii>= _N){
        ii=0;
    }
    
    val = table[i]+((table[ii]-table[i])*frac);
}
//------------------------------------------------------
// Class:       TChineseCalendar
// Function:    CurrentMajorSolarTerm
// Arguments:   TReal
//
// Comments:    Returns the index of the last major solar term
//
// Return:      see comment
//------------------------------------------------------
TReal TChineseCalendar::CurrentMajorSolarTerm(TReal& aJulianDay) const
	{
	TReal sigma;
	TInt sigmaI;

	AdjustJDToNoon(aJulianDay);

	sigma = ChineseTimeZone(aJulianDay);
	sigma = UniversalFromLocal(aJulianDay,sigma);
	SolarLongitude(sigma,sigma);
	sigma /= 30.0;
	Floor(sigmaI,sigma);
	sigmaI += 2;
	Amod(sigma,sigmaI,12.0);
	Round(sigmaI,sigma);
	return sigmaI;
	}
//------------------------------------------------------
// Class:       TChineseCalendar
// Function:    ChineseNewMoonOnOrAfter
// Arguments:   TReal
//
// Comments:    corrects for chinese month starting at noon
//				in Beijing
//
// Return:      TInt - new moon
//------------------------------------------------------
TInt TChineseCalendar::ChineseNewMoonOnOrAfter(TReal aJulianDay) const
	{
	TReal newMoon;
	TReal timeZone;
	TInt rtn;

	AdjustJDToNoon(aJulianDay);

	timeZone = ChineseTimeZone(aJulianDay);
	newMoon = UniversalFromLocal(aJulianDay,timeZone);
	newMoon = NewMoonAtOrAfter(newMoon);
	newMoon = LocalFromUniversal(newMoon,timeZone);

	AdjustJDFromNoon(newMoon);
	Floor(rtn,newMoon);

	return rtn;
	}