int main( int argc, char *argv[] ) { QApplication app(argc, argv); const char *start_path = "/space/projects/2011_12_micah"; QDir xdir( start_path ); if( !xdir.exists(start_path) ) { start_path = ""; } std::string filename = QFileDialog::getOpenFileName(0,0,start_path, "*.jplace").toStdString(); if( filename.empty() ) { return 0; } // const char *filename = "/space/projects/2011_12_micah/RAxML_portableTree.colpodea.jplace"; EPAViewerWidget evw(filename.c_str()); evw.show(); app.exec(); }
transf PositionStateEllipsoid::getCoreTran() const { double a = getParameter("a"); double b = getParameter("b"); double c = getParameter("c"); double beta = readVariable("beta"); double gamma = readVariable("gamma"); double tau = readVariable("tau"); double distance = readVariable("dist"); double px,py,pz; px = a * cos(beta) * cos(gamma); py = b * cos(beta) * sin(gamma); pz = c * sin(beta); //compute normal direction - for some reason this always points INSIDE the ellipsoid vec3 n1( -a*sin(beta)*cos(gamma), -b*sin(beta)*sin(gamma), c*cos(beta) ); vec3 n2( -a*cos(beta)*sin(gamma), b*cos(beta)*cos(gamma), 0 ); vec3 normal = normalise(n1) * normalise(n2); vec3 xdir(1,0,0); vec3 ydir = normal * normalise(xdir); xdir = ydir * normal; mat3 r(xdir,ydir,normal); transf handTran = transf(r, vec3(px,py,pz) - distance * normal); Quaternion zrot(tau, vec3(0,0,1)); handTran = transf(zrot, vec3(0,0,0) ) * handTran; return mHand->getApproachTran().inverse() * handTran; //So: hand tranform is: move onto the ellipsoid and rotate z axis in normal direction // --> hand approach transform inverted to get to hand origin }
void Train::updateOrientate(const IG::Vector2& p0,const IG::Vector2& p1) { IG::Vector2 dir=(p1-p0); dir.normalise(); IG::Vector2 xdir(1.0f,0.0f); float leng=dir.length(); leng=1.0f/leng; float angle=acos(dir.x); angle*=(180.0f/3.1415926f); if(m_pSprite!=NULL) { float currentAngle=m_pSprite->getRotation(); angle=currentAngle+(angle-currentAngle)*0.05f; m_pSprite->setRotation(angle); } }
bool AuthorizationManager::local_checkActive(QString user){ //Check for X Sessions first (don't show up with normal login verification tools) QDir xdir("/tmp/.X11-unix"); qDebug() << "Check local user activity:" << user; if(xdir.exists() && !xdir.entryList(QDir::System | QDir::NoDotAndDotDot, QDir::Name).isEmpty() ){ //Found an active graphical session - check for active processes associated with the user QString res = sysadm::General::RunCommand("ps",QStringList() << "-U" << user << "-x"); //qDebug() << "PS list length:" << res.split("\n").length(); return (res.split("\n").length()>2); //more than 1 active process for this user (labels + shell/desktop + tool used to communicate with sysadm) }else{ //No X sessions - look for normal login sessions QStringList active = sysadm::General::RunCommand("users").section("\n",0,0).split(" "); //qDebug() << "active users" << active; return active.contains(user); } }
//| /// void LC3EnemyLook(struct SquareData *felt, struct LC3Brain *mem) void LC3EnemyLook(struct SquareData *felt, struct LC3Brain *mem) { int f; /* Bask fjender !! */ if (felt[1].Team+felt[2].Team+felt[3].Team+felt[4].Team) { for (f = 1 ; f <= 4 ; f++) { if (felt[f].Team) { mem->xdest = mem->xpos+xdir(f); mem->ydest = mem->ypos+ydir(f); mem->status = LC_Status_Searching; mem->num = LCDanger; break; } } } }
void CMatrix44f::SetUpVector(float3& up) { float3 zdir(m[8],m[9],m[10]); float3 xdir(zdir.cross(up)); xdir.Normalize(); zdir=up.cross(xdir); m[0]=xdir.x; m[1]=xdir.y; m[2]=xdir.z; m[4]=up.x; m[5]=up.y; m[6]=up.z; m[8]=zdir.x; m[9]=zdir.y; m[10]=zdir.z; }
/* * Startup / Shutdown */ bool CThePlugin::OnStartup() { // Create std-data cache path scoped_chdir xdir(this->modloader->gamepath); { char buf[128], data0[128]; sprintf(buf, "%s%s\\", this->modloader->cachepath, "std-data"); sprintf(data0, "%s%s\\", buf, "data_0"); this->cachePath = buf; DestroyDirectoryA(buf); Log("Creating data cache folder..."); MakeSureDirectoryExistA(buf); MakeSureDirectoryExistA(data0); // for dat and cfg files } return true; }
//***************************************************************************** // CONSTRUCTOR: ossimLsrSpace // // Constructs the space given origin, and Y and Z ECEF directions. The int // argument is a place holder only and not used. // //***************************************************************************** ossimLsrSpace::ossimLsrSpace(const ossimEcefPoint& origin, int /* x_not_provided_space_holder */, const ossimEcefVector& y_dir_ecf_vec, const ossimEcefVector& z_dir_ecf_vec) : theOrigin (origin) { //*** // Compute the remaining axis given first two: //*** ossimColumnVector3d ydir (y_dir_ecf_vec.data().unit()); ossimColumnVector3d zdir (z_dir_ecf_vec.data().unit()); ossimColumnVector3d xdir (ydir.cross(zdir)); //*** // Fill the rotation matrix: //*** theLsrToEcefRotMatrix = ossimMatrix3x3::create(xdir[0], ydir[0], zdir[0], xdir[1], ydir[1], zdir[1], xdir[2], ydir[2], zdir[2]); }
/// void LC3FoodLook(struct SquareData *felt, struct LC3Brain *mem) void LC3FoodLook(struct SquareData *felt, struct LC3Brain *mem) { int f; /* Kig efter mad */ if (felt[1].NumFood+felt[2].NumFood+felt[3].NumFood+felt[4].NumFood) { for (f = 1 ; f <= 4 ; f++) { if (felt[f].NumFood > felt[f].NumAnts) { mem->xdest = mem->xpos+xdir(f); mem->ydest = mem->ypos+ydir(f); break; } } } if (felt->NumFood > felt->NumAnts) { mem->xdest = mem->xpos; mem->ydest = mem->ypos; mem->num = felt->NumFood-felt->NumAnts; mem->status = LC_Status_FoundFood; } }
/* * Called after all files have been processed */ bool CThePlugin::PosProcess() { // Iterate on the asi list loading each asi file for(auto& asi : this->asiList) { scoped_chdir xdir(asi.folder.c_str()); SetLastError(0); // .... bool bLoaded = asi.Load(); if(asi.bIsMainExecutable == false) { Log("[%s] %s \"%s\"; errcode: 0x%X", (asi.bIsASI? "ASI" : asi.bIsD3D9? "D3D9" : "???"), (bLoaded? "Module has been loaded:" : "Failed to load module"), asi.path.c_str(), GetLastError()); } } return true; }
void StereoReconstructor::computeCoordinate(std::string corners, std::string coord, int x, int y) { //读取所有的角点 std::ifstream file(corners.c_str()); std::vector<cv::Point3f> corner; corner.reserve(x*y); cv::Point3f point; while (file >> point.x >> point.y >> point.z) { corner.push_back(point); } file.close(); //计算x方向 cv::Point3f pd = corner[x - 1] - corner[0]; cv::Point3f xdir(0, 0, 0); for (int i = 0; i < y; i++) { std::vector<cv::Point3f> tps; //提取x方向的点 for (int j = 0; j < x; j++) { cv::Point3f tp = corner[i*x + j]; tps.push_back(tp); } cv::Point3f td = Utilities::lineFit(tps); xdir += td; } xdir.x = xdir.x / y; xdir.y = xdir.y / y; xdir.z = xdir.z / y; if (pd.dot(xdir) < 0) { xdir = -xdir; } double xv[] = {xdir.x, xdir.y, xdir.z}; double normal = sqrt(xv[0] * xv[0] + xv[1] * xv[1] + xv[2] * xv[2]); xv[0] /= normal; xv[1] /= normal; xv[2] /= normal; //计算y方向 cv::Point3f pyd = corner[x] - corner[0]; cv::Point3f ydir(0, 0, 0); for (int i = 0; i < x; i++) { std::vector<cv::Point3f> tps; //提取y方向的点 for (int j = 0; j < y; j++) { cv::Point3f tp = corner[j*x + i]; tps.push_back(tp); } cv::Point3f td = Utilities::lineFit(tps); ydir += td; } ydir.x = ydir.x / x; ydir.y = ydir.y / x; ydir.z = ydir.z / x; if (pyd.dot(ydir) < 0) { ydir = -ydir; } double yv[] = {ydir.x, ydir.y, ydir.z}; normal = sqrt(yv[0] * yv[0] + yv[1] * yv[1] + yv[2] * yv[2]); yv[0] /= normal; yv[1] /= normal; yv[2] /= normal; //计算坐标系 double zv[3]; zv[0] = xv[1] * yv[2] - xv[2] * yv[1]; zv[1] = xv[2] * yv[0] - xv[0] * yv[2]; zv[2] = xv[0] * yv[1] - xv[1] * yv[0]; //保存到坐标系文件 std::ofstream coordinate(coord); coordinate << corner[0].x << '\t' << corner[0].y << '\t' << corner[0].z << std::endl; coordinate << xv[0] << '\t' << xv[1] << '\t' << xv[2] << std::endl; coordinate << yv[0] << '\t' << yv[1] << '\t' << yv[2] << std::endl; coordinate << zv[0] << '\t' << zv[1] << '\t' << zv[2] << std::endl; coordinate.close(); }