예제 #1
0
bool MonocularManhattanBnb::Compute(const PosedCamera& pcam,
                                    const vector<ManhattanEdge> edges[],
                                    const MatI& orients) {
	pc = &pcam;

	vert_axis = 0;
	for (int i = 1; i < 3; i++) {
		if (abs(pc->GetRetinaVpt(i)[1]) > abs(pc->GetRetinaVpt(vert_axis)[1])) {
			vert_axis = i;
		}
	}

	enumerator.Configure(pcam, vert_axis);
	evaluator.Configure(pcam, vert_axis);

	DownsampleOrients(orients, est_orients, makeVector(*gvOrientRes, *gvOrientRes));

	soln_score = numeric_limits<int>::min();
	hypothesis_count = 0;
	if (enumerator.Compute(edges,
			bind(&MonocularManhattanBnb::EvaluateHypothesis, this, _1))) {
		evaluator.PredictImOrientations(soln, soln_orients);
		DLOG << "Evaluated " << hypothesis_count << " hypotheses";
		return true;
	} else {
		return false;
	}
}
예제 #2
0
void MonocularManhattanBnb::TransferBuilding(const SE3<>& new_pose,
                                             double floor_z,
                                             MatI& orients) {
	// Compute scaling (TODO: actually use this)
	DiagonalMatrix<3> Mscale(makeVector(1.0*orients.Cols()/pc->image_size()[0],
																			1.0*orients.Rows()/pc->image_size()[1],
																			1.0));

	// Invert the pose
	const SE3<> orig_inv = pc->pose().inverse();

	orients.Fill(vert_axis);
	for (ManhattanBuilding::ConstCnrIt left_cnr = soln.cnrs.begin();
			successor(left_cnr) != soln.cnrs.end();
			left_cnr++) {
		ManhattanBuilding::ConstCnrIt right_cnr = successor(left_cnr);

		//TITLE("Next corner");
		int axis = OtherHorizAxis(left_cnr->right_axis);

		// Compute vertices in the 3D camera frame
		Vec3 bl = FloorPoint(left_cnr->right_floor, floor_z);
		Vec3 br = FloorPoint(right_cnr->left_floor, floor_z);
		Vec3 tl = CeilPoint(left_cnr->right_ceil, bl);
		Vec3 tr = CeilPoint(right_cnr->left_ceil, br);
		if (bl[2] < 0) {
			bl = -bl;
			br = -br;
			tl = -tl;
			tr = -tr;
		}
		// Compute vertices in the 3D global frame
		Vec3 world_tl = orig_inv * tl;
		Vec3 world_tr = orig_inv * tr;
		Vec3 world_bl = orig_inv * bl;
		Vec3 world_br = orig_inv * br;

		// Compute the wall corners in the other camera
		Vec3 ret_tl = new_pose * world_tl;
		Vec3 ret_tr = new_pose * world_tr;
		Vec3 ret_bl = new_pose * world_bl;
		Vec3 ret_br = new_pose * world_br;
		ClipToFront(ret_tr, ret_tl);
		ClipToFront(ret_br, ret_bl);

		// Compute the wall corners in the other image
		Vec3 im_tl = pc->RetToIm(ret_tl);
		Vec3 im_tr = pc->RetToIm(ret_tr);
		Vec3 im_bl = pc->RetToIm(ret_bl);
		Vec3 im_br = pc->RetToIm(ret_br);

		// Build the polygon and fill
		vector<Vec3 > poly;
		poly.push_back(im_tl);
		poly.push_back(im_bl);
		poly.push_back(im_br);
		poly.push_back(im_tr);
		FillPolygon(poly, orients, axis);
	}
}
예제 #3
0
int main( int argc, char** argv ) {
 
  Vector a = makeVector(3.0,4.0,5.0);
  Vector b = makeVector(4.0,6.0,9.0);
  printVector(a);
  printf("\n");
  printVector(b);
  printf("\n");
  
  Vector sum;
  sum  = add(a,b);
  printf("Sum of the Vectors: ");
  printVector(sum);   //prints sum of two vectors
  printf("\n"); 
/*
  Vector difference;
  difference = diff(a,b);
  printf("Difference of the Vectors: ");
  printVector(diff);   //prints difference of two vectors
  printf("\n"); 
*/
 
  Vector crossProd;
  crossProd = crossProduct(a,b);
  printf("The cross product of the Vectors: ");
  printVector(crossProd);   //prints the cross product of two vectors
  printf("\n"); 

  double dotProd = dotProduct(a,b);
  printf("Dot product of the two vectors: %5.5f ", dotProd); // prints   dot product of the two vectors
  printf("\n");

  double magA = magnitude(a);
  printf("Magnitude of vector 'a': %5.5f ", magA);// prints the magnitude of the vector
  printf("\n");
  double magB  = magnitude (b);
  printf("Magnitude of vector 'b': %5.5f ", magB);// prints the magnitude of the vector
  printf("\n");

  
  
  return 0;
 

  

} // main( int, char** )
void generatePageRanks(std::vector<WebPage*>& pages)
{
#if DEBUG
	mergeSort(pages, FileNameComp());
#endif

	// prevent divide by zero errors
	if (pages.size() == 0)
	{
		return;
	}

	// get the matrix
	Matrix m = makeMatrix(pages);
	// get the starting vector
	std::vector<double> v = makeVector(pages.size());

#if DEBUG
	// debugging output
	std::cout << "Matrix:" << std::endl;
	for (size_t x = 0; x < m.mySize; ++ x)
	{
		for (size_t y = 0; y < m.mySize; ++ y)
		{
			std::cout << m[x][y] << "\t";
		}
		std::cout << std::endl;
	}
	std::cout << "Vector:" << std::endl;
	for (size_t x = 0; x < v.size(); ++ x)
	{
		std::cout << v[x] << "\t";
	}
	std::cout << std::endl;
#endif

	// iterate and calculate
	for (size_t i = 0; i < NUM_ITERATIONS; ++ i)
	{
		multiply(m, v);
	}

#if DEBUG
	std::cout << "Answer:" << std::endl;
	for (size_t x = 0; x < v.size(); ++ x)
	{
		std::cout << v[x] << "\t";
	}
	std::cout << std::endl;
#endif

	// put the values in the pages
	std::vector<WebPage*>::iterator i = pages.begin();
	for (size_t ind = 0; ind < v.size(); ++ ind)
	{
		(*i)->setPageRank(v[ind]);
		++ i;
	}
}
void BuildingStoryUnassignedSpacesVectorController::onChangeRelationship(const model::ModelObject& modelObject, int index, Handle newHandle, Handle oldHandle)
{
  if (modelObject.optionalCast<model::Space>()){
    if (index == OS_SpaceFields::BuildingStoryName){
      emit itemIds(makeVector());
    }
  }
}
예제 #6
0
void NameManager::setIfName(id_offset id, std::string new_name) {
  name_map::iterator it = id_to_inst.find(id);

  if (it != id_to_inst.end()) {
    uint32_t string_pos = getStringPosition(it->second->opcode());
    it->second->SetInOperand(string_pos, std::move(makeVector(new_name.c_str())));
  }
}
예제 #7
0
void SpaceSpaceInfiltrationDesignFlowRateVectorController::onChangeRelationship(const model::ModelObject& modelObject, int index, Handle newHandle, Handle oldHandle)
{
    if (modelObject.optionalCast<model::SpaceInfiltrationDesignFlowRate>()) {
        if (index == OS_SpaceInfiltration_DesignFlowRateFields::SpaceorSpaceTypeName) {
            emit itemIds(makeVector());
        }
    }
}
예제 #8
0
파일: Ploter.cpp 프로젝트: MarwanG/Graal
void Ploter::plotCorrectedHll(string filename){
	ofstream file(filename);
	string line;
	int x1, x2;
	double y1, y2;
	x1 = 0;
	y1 = 0;
	x2 = CARDMAX/STEP-1;
	y2 = 0;
	uint64_t hash;
	uint64_t hash128[2];
	
	vector<double> estimates = makeVector();
	
	int i;
	vector< vector<double> > tab(CARDMAX/STEP, vector<double>(TESTS));
	
	int ca = 0;
	for(i = 0; i < TESTS; i ++){
		cout << i << endl;
		Hll hll(14);
		
		for(int j = 0; j < CARDMAX; j++){
			MurmurHash3_x86_128(&ca, 4, 0, &hash128);
			ca++;
			hash = hash128[0];
			hll.AddItem64(hash);
			if(j%STEP == 0){
				double count = hll.CountRaw64();
				for(int i = 0; i < CARDMAX/STEP-1; i++){
					if(estimates[i] <= count && count < estimates[i+1]){
						x1 = estimates[i];
						y1 = i*STEP;
						x2 = estimates[i+1];
						y2 = (i+1)*STEP;
						count = interpolation(count, x1, y1, x2, y2);
					}
				}
				//count = interpolation(count, x1, y1, x2, y2);
				//count = (double)abs(count-j)/j;
				tab[j/STEP][i]=count;
			}
		}
	}
	
	for(int j = 0; j < CARDMAX/STEP; j++){
		double sum = 0;
		for (int k = 0; k < TESTS; k++){
			sum= sum + tab[j][k];
		}
		//cout << sum << endl;
		double median = percentile(tab[j],0.5);
		double pct01 = percentile(tab[j],0.01);
		double pct99 = percentile(tab[j],0.99);
		file << (j*STEP) << "\t" << (double)sum/TESTS << "\t" << (double)median << "\t" << pct01 << "\t" << pct99 << endl;
	}
	
}
예제 #9
0
//Left/Right Movement
void Camera::strafeCamera(float distance){
	Vector vec = makeVector(ViewVector.x-PositionVector.x,
			ViewVector.y-PositionVector.y,
			ViewVector.z-PositionVector.z);
	PositionVector.x = PositionVector.x - vec.z*distance;
	PositionVector.z = PositionVector.z + vec.x*distance;
	ViewVector.x = ViewVector.x - vec.z*distance;
	ViewVector.z = ViewVector.z + vec.x*distance;
}
예제 #10
0
//----------------------------------------------------------
/// @brief	_vertexで表される面を三角形分割し、_trisに格納する
/// @ref		http://javaappletgame.blog34.fc2.com/blog-entry-148.html
void CWall::SplitTriangles(){
	vector< pair<double,double> > v = _vertex;	// コピー
	_tris.clear();	// _trisの初期化
	while( v.size() >= 3 ){
		// 原点から最も遠い点を探す
		int mfar = 0;
		for(int i=1; i<v.size(); i++){
			if( v[mfar].first*v[mfar].first+v[mfar].second*v[mfar].second < v[i].first*v[i].first+v[i].second*v[i].second )
				mfar = i;
		}
		// 最も遠い点から伸びる2つのベクトルを生成
		t_vector v1, v2;
		v1 = makeVector( v[mfar], v[(mfar+1)%v.size()] );
		v2 = makeVector( v[mfar], v[(mfar+v.size()-1)%v.size()] );
		// 三角形内部に点があるとき
		if( IsExistPointInTriangle(v1, v2, v) ){
			// 外積の記録
			double cr = cross( v1, v2 );
			// 見つかるまでループ
			while(1){
				// 1つ横の点を選ぶ
				mfar = (mfar+1)%v.size();
				// ベクトル生成
				v1 = makeVector( v[mfar], v[(mfar+1)%v.size()] );
				v2 = makeVector( v[mfar], v[(mfar+v.size()-1)%v.size()] );
				// 外積の符号が異なる→ループ最初に戻る
				if( cr*cross(v1,v2) < 0.0 )	continue;
				// 内部に点があるか確認
				// 点がある→ループ最初に戻る
				if( IsExistPointInTriangle(v1, v2, v) )	continue;
				// 点がない→脱ループ
				break;
			}
		}
		// 三角形の3点を_trisに記録
		t_triangle t;
		t.x[0] = v1.sx;			t.y[0] = v1.sy;
		t.x[1] = v1.sx+v1.vx;	t.y[1] = v1.sy+v1.vy;
		t.x[2] = v2.sx+v2.vx;	t.y[2] = v2.sy+v2.vy;
		_tris.push_back(t);
		// 選ばれた点をvから除外
		v.erase( remove( v.begin(), v.end(), v[mfar] ) );
	}
}
예제 #11
0
sf::Vector2f Planet::toProjection(sf::Vector2f point, float radius) {
	float circumference = 2 * PI * radius;

	float r = sqrt(pow(point.x, 2) + pow(point.y, 2));
	float angle = toDegrees(atan2(point.y, point.x));

	float r2 = (sqrt(r) * sqrt(circumference / 4)) / (circumference / 4) * radius;
	sf::Vector2f pos = makeVector(angle, r2, sf::Vector2f(radius, radius));

	return pos;
}
예제 #12
0
sf::Vector2f Planet::toPlane(sf::Vector2f point, float radius) {
	float circumference = 2 * PI * radius;

	float r = sqrt(pow(point.x, 2) + pow(point.y, 2));
	float angle = toDegrees(atan2(point.y, point.x));

	float r2 = (pow(r, 2) / radius) / radius * (circumference / 4);
	sf::Vector2f pos = makeVector(angle, r2, sf::Vector2f(circumference / 4, circumference /4));

	return pos;
}
예제 #13
0
void ManhattanBranchAndBound::Configure(const PosedCamera& pcam, int v_axis) {
	pc = &pcam;

	// Compute size of a pixel
	Vec2 a = pc->RetToIm(makeVector(0.0, 0.0));
	Vec2 b = pc->RetToIm(makeVector(1.0, 1.0));
	px_diam = 1 / norm(a-b);

	// Cache the vanishing points for efficiency
	for (int i = 0; i < 3; i++) {
		vpts[i] = pcam.GetRetinaVpt(i);
	}
	vert_axis = v_axis;
	h1_axis = (vert_axis + 1) % 3;
	h2_axis = (vert_axis + 2) % 3;
	vert_vpt = vpts[vert_axis];

	// Ensure the horizon line has its positive side at the top of the image
	horizon = vpts[h1_axis] ^ vpts[h2_axis];
	if (horizon[1] < 0) horizon = -horizon;
}
예제 #14
0
void Planet::accelerateObject(Entity *entity) {
	sf::Vector2f position = entity->getPosition();
	sf::Vector2f velocity = entity->getVelocity();

	float a = angle(position, m_position);
	float d = distance(position, m_position);
	d = (d == 0 ? (float)0.001 : d);
	float force = GRAVITATIONAL_CONSTANT * entity->getMass() * this->getMass() / pow(d, 2);
	float acceleration = force / entity->getMass();

	velocity += makeVector(a, acceleration);
	entity->setVelocity(velocity);
}
void UtilityBillFuelTypeListController::objectRemoved(boost::shared_ptr<openstudio::detail::WorkspaceObject_Impl> impl, const openstudio::IddObjectType& iddObjectType, const openstudio::UUID& handle)
{
  if (iddObjectType == m_iddObjectType){
    // in a ModelObjectTypeListView this is sufficient to say that a new item has been added to our list
    // however, in this case we need to also check the fuel type
    if (boost::dynamic_pointer_cast<model::detail::UtilityBill_Impl>(impl)){
      if (boost::dynamic_pointer_cast<model::detail::UtilityBill_Impl>(impl)->fuelType() == m_fuelType){

        emit itemIds(makeVector());
      }
    }
  }
}
예제 #16
0
/*--------------------------------------------------------------------*/
static MATRIX uFromAngles(double om, double sgu, double sgl){
  MATRIX u;

  u = makeVector();
  if(u == NULL){
    return NULL;
  }
  vectorSet(u,0,-Cosd(sgl)*Cosd(om));
  vectorSet(u,1,Cosd(sgu)*Sind(om) - Sind(sgu)*Sind(sgl)*Cosd(om));
  vectorSet(u,2,-Sind(sgu)*Sind(om) - Cosd(sgu)*Sind(sgl)*Cosd(om));
  
  return u;	    
}
예제 #17
0
//Look around
void Camera::rotateCamera(float x, float y){
	float angleY = 0.0f;
	float angleZ = 0.0f;
	angleY = x/250;
	angleZ = y/50;
	ViewVector.y+=angleZ*3;
	//Rotate_View(-angle_y);
	Vector vec = makeVector(ViewVector.x-PositionVector.x,
			ViewVector.y-PositionVector.y,
			ViewVector.z-PositionVector.z);
	ViewVector.z = (float) (PositionVector.z + sin(-angleY)*vec.x + cos(-angleY)*vec.z);
	ViewVector.x = (float) (PositionVector.x + cos(-angleY)*vec.x - sin(-angleY)*vec.z);
}
예제 #18
0
	void LoadMapFromVoodooTextFile(const string& text_file,
																 const string& image_pattern,
																 Map& map) {
		static const string kMagic = "#timeindex";
		static const string kPointsHeader = "# 3D Feature Points";
		sifstream in(expand_path(text_file));

		double Cx, Cy, Cz, Ax, Ay, Az, Hx, Hy, Hz, Vx, Vy, Vz, K3, K5;
		double sx, sy, Width, Height, ppx, ppy, f, fov;
		double H0x, H0y, H0z, V0x, V0y, V0z;

		DLOG << "WARNING: using first camera intrinsics for all cameras";
		int i = 0;
		Vec3 v;
		bool reading_points = false;
		boost::format image_fmt(image_pattern);
		while (!in.eof()) {
			if (reading_points) {
				in >> v[0] >> v[1] >> v[2];
				map.points.push_back(v);
			} else {
				string line;
				getline(in, line);
				if (line.substr(0,kMagic.size()) == kMagic) {
					int id = lexical_cast<int>(line.substr(kMagic.size()+1));
					in >> Cx >> Cy >> Cz >> Ax >> Ay >> Az
						 >> Hx >> Hy >> Hz >> Vx >> Vy >> Vz >> K3 >> K5
						 >> sx >> sy >> Width >> Height >> ppx >> ppy >> f >> fov
						 >> H0x >> H0y >> H0z >> V0x >> V0y >> V0z;
				
					string image_file = str(image_fmt % 21);//id);
					CHECK_PRED1(fs::exists, image_file);

					Mat3 C;
					C[0] = makeVector(f/sx, 0, ppx);
					C[1] = makeVector(0, f/sy, ppx);
					C[2] = makeVector(0, 0, 1);
					if (i == 0) {
						Vec2I image_size = GetImageSize(expand_path(image_file));
						map.camera.reset(new LinearCamera(C, image_size));
					}

					Mat3 R;
					R[0] = makeVector(H0x, H0z, H0y);
					R[1] = makeVector(V0x, V0z, V0y);
					R[2] = makeVector(Ax, Az, Ay);
					Vec3 t = makeVector(-Cx, -Cy, -Cz);
					SE3<> pose(SO3<>(R), t);

					map.AddFrame(new Frame(id, image_file, pose));

					i++;
				} else if (line.substr(0, kPointsHeader.size()) == kPointsHeader) {
예제 #19
0
파일: answer.cpp 프로젝트: Altynai/LeetCode
 void dfs(vector<vector<int> > &result, vector<int> &candidates, vector<int> &limits, int space, int index, vector<int> &count) {
     if (space == 0) {
         result.push_back(makeVector(index, candidates, count));
         return;
     }
     int n = candidates.size();
     if (n == index)
         return;
     int choice = std::min(limits[index], space / candidates[index]);
     for (int i = choice; i >= 0; i--) {
         count[index] = i;
         dfs(result, candidates, limits, space - candidates[index] * i, index + 1, count);
     }
 }
예제 #20
0
파일: Matrix.c 프로젝트: awesome/gloss
Vector mvMulDir(const Matrix matrix, const Vector vector) {

	Vector newVector = makeVector(0, 0, 0);

	// Access x,y,z as an array.
	float* vectorValues	= (float*)&vector.x;
	float* newVectorValues = (float*)&newVector.x;

	for (int i=0; i<3; i++)
		for (int j=0; j<3; j++)
			newVectorValues[i] +=  matrix.values[i][j] * vectorValues[j];

	return newVector;
}
예제 #21
0
/*-----------------------------------------------------------------------------*/
static MATRIX tasReflectionToQC(tasQEPosition r, MATRIX UB){
  MATRIX Q, QC;

  Q = makeVector();
  if(Q == NULL){
    return NULL;
  }
  vectorSet(Q,0,r.qh);
  vectorSet(Q,1,r.qk);
  vectorSet(Q,2,r.ql);
  QC = mat_mul(UB,Q);
  killVector(Q);
  return QC;
}
예제 #22
0
/*==================== reciprocal space ==============================*/
static MATRIX tasReflectionToHC(tasQEPosition r, MATRIX B){
  MATRIX h = NULL, hc = NULL;

  h = makeVector();
  if(h == NULL){
    return NULL;
  }
  vectorSet(h,0,r.qh);
  vectorSet(h,1,r.qk);
  vectorSet(h,2,r.ql);

  hc = mat_mul(B,h);
  killVector(h);
  return hc;
}
예제 #23
0
void SpaceDesignSpecificationOutdoorAirVectorController::onChangeRelationship(const model::ModelObject& modelObject, int index, Handle newHandle, Handle oldHandle)
{
    if (modelObject.optionalCast<model::Space>()) {
        if (index == OS_SpaceFields::DesignSpecificationOutdoorAirObjectName) {
            emit itemIds(makeVector());
        } else if (index == OS_SpaceFields::SpaceTypeName) {
            detachOtherModelObjects();
            model::Space space = m_modelObject->cast<model::Space>();
            attachOtherModelObjects(space);
            emit itemIds(makeVector());
        }
    } else if (modelObject.optionalCast<model::Building>()) {
        if (index == OS_BuildingFields::SpaceTypeName) {
            detachOtherModelObjects();
            model::Space space = m_modelObject->cast<model::Space>();
            attachOtherModelObjects(space);
            emit itemIds(makeVector());
        }
    } else if (modelObject.optionalCast<model::SpaceType>()) {
        if (index == OS_SpaceTypeFields::DesignSpecificationOutdoorAirObjectName) {
            emit itemIds(makeVector());
        }
    }
}
void calculateEdgeLength(pMesh theMesh, GeomData *pGCData){
	int dim = theMesh->getDim();
	//double max_edge=.0, avgLength=.0;
	double elength, Lij[dim];
	double Icoord[3], Jcoord[3];
	double delta_x = 1e30; // infinity delta_x
	double versor[3];
	int i,j;
	dblarray vec(3);
	EIter eit = M_edgeIter(theMesh);
	while (pEntity edge = EIter_next(eit)){
		if (!theMesh->getRefinementDepth(edge)){
			E_getVerticesCoord(edge,Icoord,Jcoord);
			for (j=0; j<dim; j++){
				Lij[j] = .0;
			}
			makeVector(Jcoord,Icoord,Lij);
			for (i=0; i<dim; i++){
				vec[i] = Lij[i];
			}
			elength = .0;
			for (i=0; i<dim; i++){
				elength += vec[i]*vec[i];
			}
			elength = sqrt(elength);
			if (elength == .0){
				char msg[256]; sprintf(msg,"Edge [%d %d] has null length!",EN_id(edge->get(0,0)),EN_id(edge->get(0,1)));
				throw Exception(__LINE__,__FILE__,msg);
			}
			//cout << "elength = " << elength << endl;
			pGCData->setEdgeLength(edge,elength);
			for (i=0; i<dim; i++){
				vec[i] /= elength;
			}
			//pGCData->setEdgeVec_Unitary(edge,vec);
			versor[0] = vec[0]; versor[1] = vec[1]; versor[2] = vec[2];
			pGCData->setVersor(edge,versor);

			// get the smallest one
			if (delta_x > elength){
				delta_x = elength;
			}
		}
	}
	EIter_delete(eit);//throw 1;
	// if parallel, get the smallest edge from all ranks and then broadcast it.
	pGCData->setSmallestEdgeLength(P_getMinDbl(delta_x));
}
예제 #25
0
int main(int argc, char ** argv)
{
    (void) argc;
    std::ifstream input{argv[1]};
    std::string line;

    std::getline(input, line);
    while(input)
    {
        auto data = makeVector(line);
        auto pivotCount = countPivots(std::move(data));
        std::cout << pivotCount << '\n';
        std::getline(input, line);
    }
    return 0;
}
예제 #26
0
bool LevelDBDatabase::get(const LevelDBSlice& key, Vector<char>& value)
{
    std::string result;
    leveldb::ReadOptions readOptions;
    readOptions.verify_checksums = true; // FIXME: Disable this if the performance impact is too great.

    const leveldb::Status s = m_db->Get(readOptions, makeSlice(key), &result);
    if (s.ok()) {
        value = makeVector(result);
        return true;
    }
    if (s.IsNotFound())
        return false;
    LOG_ERROR("LevelDB get failed: %s", s.ToString().c_str());
    return false;
}
예제 #27
0
파일: pilot.c 프로젝트: callaa/luola
/* Initialize all pilots */
void reinit_pilots(void) {
    int plr,r;
    dllist_free(pilot_list,NULL);
    pilot_list = 0;

    for(plr=0;plr<4;plr++) {
        memset (&players[plr].pilot, 0, sizeof (Pilot));

        init_walker(&players[plr].pilot.walker);
        players[plr].pilot.walker.physics.radius = PILOT_STD_RADIUS;

        for (r = 0; r < 3; r++)
            players[plr].pilot.sprite[r] = pilot_sprite[plr][r];
        players[plr].pilot.attack_vector = makeVector(1,0);
    }
}
예제 #28
0
// Codifica uma entrada num arquivo binario utilizando a codificação de Shannon-Fano
string encode(string *input, int *sizeB, int *sizeA)
{
    std::vector<Symbol> symbols;
    unsigned short num_bit = 1;
    bool flag = false;
    string file = "";

    if ((input != NULL) && (!input->empty()))
    {
        file = *input;
        flag = readFile(input);
    }
    
    if (flag)
    {
        *sizeB = input->size();
        
        makeVector(*input,symbols); // Constroi o vector com os simbolos

        while (symbols.size() > pow(2,num_bit)) // Conta quantos bits serao necessarios para representar os simbolos
            num_bit++;

        makeCodes(symbols); // Cria os codigos em Shannon-Fano de cada simbolo
        
        string encoded = charToSF(*input,symbols); // String com a mensagem na codificação de Shannon-Fano

        input->clear();
        
        string output = outArvore(symbols, encoded, input); // Saida do algoritmo de Shannon-Fano

        *sizeA = output.size();
        
        writeOutput(output, &file); // Escreve a(s) saida(s) no arquivo

        // Limpando memoria

        symbols.clear();
    
        // ---------------
        
        return output;
    }
    
    return "";
}
예제 #29
0
int main(int argc, char **argv) {
	InitVars(argc, argv);
	if (argc != 4) {
		DLOG << "Usage: "<<argv[0]<<" truthed_map.pro BASE_INDEX AUX_RANGE";
		return 0;
	}

	// Input arguments
	const char* path = argv[1];
	int base_id = atoi(argv[2]);
	vector<int> aux_ids = ParseMultiRange<int>(string(argv[3]));
	// Never use the base frame as an auxiliary frame
	vector<int>::iterator new_end = remove(aux_ids.begin(), aux_ids.end(), base_id);
	aux_ids.erase(new_end, aux_ids.end());

	format filepat("out/%s");
	DREPORT(base_id, iowrap(aux_ids));

	// Load the map
	Map map;
	proto::TruthedMap gt_map;
	map.LoadWithGroundTruth(path, gt_map);

	// Get the floor and ceiling positions
	double zfloor = gt_map.floorplan().zfloor();
	double zceil = gt_map.floorplan().zceil();
	Vec3 vup = map.kfs[0].pc->pose_inverse() * makeVector(0,1,0);
	if (Sign(zceil-zfloor) == Sign(vup[2])) {
		swap(zfloor, zceil);
	}

	// Set up the reconstruction
	MultiViewReconstructor mv;
	Frame* base_frame = map.KeyFrameByIdOrDie(base_id);
	base_frame->LoadImage();
	TITLED("Computing objective function for base frame")
		mv.Configure(base_frame->image, zfloor, zceil);

	BOOST_FOREACH(int aux_id, aux_ids) {
		Frame* frame = map.KeyFrameByIdOrDie(aux_id);
		frame->LoadImage();
		TITLED(str(format("Computing objective function for frame %d")%aux_id))
			mv.AddFrame(frame->image);
	}
예제 #30
0
	void LoadXmlMapWithGroundTruth(const string& path,
																 Map& map,
																 proto::TruthedMap& gt_map,
																 bool include_non_keyframes,
																 bool rotate_map) {
		ReadProto(path, gt_map);
		fs::path map_path = fs::path(*gvSequencesDir).parent_path() / gt_map.spec_file();
		LoadXmlMap(map_path.string(), map, include_non_keyframes);
		if (rotate_map) {
			map.Transform(SO3<>::exp(asToon(gt_map.ln_scene_from_slam())));
			double zfloor = gt_map.floorplan().zfloor();
			double zceil = gt_map.floorplan().zceil();
			Vec3 vup = map.frames[0].image.pc().pose_inverse() * makeVector(0,1,0);
			if (Sign(zceil-zfloor) == Sign(vup[2])) {
				gt_map.mutable_floorplan()->set_zfloor(zceil);
				gt_map.mutable_floorplan()->set_zceil(zfloor);
			}
		}
	}