コード例 #1
0
ファイル: PCA.cpp プロジェクト: caomw/3D-Feat-Desc
void // Checks the sign of the vectors
PCA::signCheck()
{	
	float signNorm = 0, signVecBase = 0;
	PCLPoint pcl_point;
	Eigen::Vector3d vec_point;
	for (size_t i = 0; i < sub_cloud_ind[0].size(); i ++)
	{
		pcl_point = (*cloud).points[sub_cloud_ind[0][i]];
		if(pcl_point.z == pcl_point.z)
		{
			pcl_point.x -= centre(0);
			pcl_point.y -= centre(1);
			pcl_point.z -= centre(2);
			vec_point << pcl_point.x, pcl_point.y, pcl_point.z;
			signNorm += normal.dot(vec_point);
			signVecBase += vec_base1.dot(vec_point);
		}
	}
	if (signNorm!=0)
		normal = normal * signNorm / fabs(signNorm);
		
	if (signVecBase!=0)
		vec_base1 = vec_base1 * signVecBase / fabs(signVecBase);
}
コード例 #2
0
ファイル: PCA.cpp プロジェクト: caomw/3D-Feat-Desc
void // Computes the covariance Matrix
PCA::computeCovar(Eigen::Matrix3d & covar)
{
	// Subtract the center & Compute the covariance Matrix
	double covxx = 0, covyy = 0, covzz = 0, covxy = 0, covxz = 0, covyz = 0;
	for(size_t i = 0; i < sub_cloud_ind[0].size(); i++)
	{
		PCLPoint point = (*cloud).points[sub_cloud_ind[0][i]];
		if(point.z == point.z)
		{
			point.x -= centre(0);
			point.y -= centre(1);
			point.z -= centre(2);
			covxx += point.x * point.x * (sub_cloud_ind[1][i] / 100.0);
			covyy += point.y * point.y * (sub_cloud_ind[1][i] / 100.0);
			covzz += point.z * point.z * (sub_cloud_ind[1][i] / 100.0);
			covxy += point.x * point.y * (sub_cloud_ind[1][i] / 100.0);
			covxz += point.x * point.z * (sub_cloud_ind[1][i] / 100.0);
			covyz += point.y * point.z * (sub_cloud_ind[1][i] / 100.0);
  	}
	}
	
	covar << 	covxx, covxy, covxz,
						covxy, covyy, covyz,
						covxz, covyz, covzz;
}
コード例 #3
0
ファイル: STAFF2.C プロジェクト: MAYURESH29/data-structure
      void display()
{     //     int f=0,m=0,tot=0;
	cleardevice();
		   // setcolor(9);
	centre(21,"WALCHAND COLLEGE OF ENGINEERING ");
	       centre(22,"SANGLI");
	       centre(23,"STAFF RECORD MANAGEMENT\n");
	printf("SNO NO: \t NAME: \t\t AGE :\t LAST EDUCATION : \t  BASIC SALARY:");
	  rewind(fa);
	while(1)
	{
		fread(&rec,sizeof(rec),1,fa);
	       //	 fclose(fa);
		if(feof(fa))
			break;
	       setbkcolor(14);






		printf("\n%4d \t\t %-15s  %4d  \t%-15s \t   %4ld  ",rec.sno,rec.nm,rec.age,rec.last_edu,rec.bs);
	}
	     //	printf("\nfemale:%4d male:%4d",f,m);

//		printf("\n total student:%4d",tot);

	getch();
	return;
}
コード例 #4
0
ファイル: PCA.cpp プロジェクト: caomw/3D-Feat-Desc
void // Computes the centre of the sub cloud
PCA::computeCentre()
{
	int nb_points = 0;
	double sum = 0;
	// Compute the means
	for(size_t i = 0; i < sub_cloud_ind[0].size(); i++)
	{
		PCLPoint point = (*cloud).points[sub_cloud_ind[0][i]];
		if(point.z == point.z)
		{
			centre(0) += point.x * sub_cloud_ind[1][i];
			centre(1) += point.y * sub_cloud_ind[1][i];
			centre(2) += point.z * sub_cloud_ind[1][i];
			sum += sub_cloud_ind[1][i];
			nb_points ++;
	  }
	}
	if (nb_points == 0)
	{
		std::cerr << "Error PCA::computeCentre no points for center computation -> division by zero " << std::endl;
		centre << 0, 0, 0;
	}
	centre /= (double)(nb_points * sum);
	
	if (centre.norm()!=centre.norm())
		std::cerr << "Error PCA::computeCentre NaN Centre" << std::endl; 
}
コード例 #5
0
ファイル: ConvertEmptyToTof.cpp プロジェクト: liyulun/mantid
/**
 * Fit peak without background i.e, with background removed
 *  inspired from FitPowderDiffPeaks.cpp
 *  copied from PoldiPeakDetection2.cpp
 *
 @param workspaceindex :: indice of the row to use
 @param center :: gaussian parameter - center
 @param sigma :: gaussian parameter - width
 @param height :: gaussian parameter - height
 @param startX :: fit range - start X value
 @param endX :: fit range - end X value
 @returns A boolean status flag, true for fit success, false else
 */
bool ConvertEmptyToTof::doFitGaussianPeak(int workspaceindex, double &center,
                                          double &sigma, double &height,
                                          double startX, double endX) {

  g_log.debug("Calling doFitGaussianPeak...");

  // 1. Estimate
  sigma = sigma * 0.5;

  // 2. Use factory to generate Gaussian
  auto temppeak = API::FunctionFactory::Instance().createFunction("Gaussian");
  auto gaussianpeak = boost::dynamic_pointer_cast<API::IPeakFunction>(temppeak);
  gaussianpeak->setHeight(height);
  gaussianpeak->setCentre(center);
  gaussianpeak->setFwhm(sigma);

  // 3. Constraint
  double centerleftend = center - sigma * 0.5;
  double centerrightend = center + sigma * 0.5;
  std::ostringstream os;
  os << centerleftend << " < PeakCentre < " << centerrightend;
  auto *centerbound = API::ConstraintFactory::Instance().createInitialized(
      gaussianpeak.get(), os.str(), false);
  gaussianpeak->addConstraint(centerbound);

  g_log.debug("Calling createChildAlgorithm : Fit...");
  // 4. Fit
  API::IAlgorithm_sptr fitalg = createChildAlgorithm("Fit", -1, -1, true);
  fitalg->initialize();

  fitalg->setProperty(
      "Function", boost::dynamic_pointer_cast<API::IFunction>(gaussianpeak));
  fitalg->setProperty("InputWorkspace", m_inputWS);
  fitalg->setProperty("WorkspaceIndex", workspaceindex);
  fitalg->setProperty("Minimizer", "Levenberg-MarquardtMD");
  fitalg->setProperty("CostFunction", "Least squares");
  fitalg->setProperty("MaxIterations", 1000);
  fitalg->setProperty("Output", "FitGaussianPeak");
  fitalg->setProperty("StartX", startX);
  fitalg->setProperty("EndX", endX);

  // 5.  Result
  bool successfulfit = fitalg->execute();
  if (!fitalg->isExecuted() || !successfulfit) {
    // Early return due to bad fit
    g_log.warning() << "Fitting Gaussian peak for peak around "
                    << gaussianpeak->centre() << '\n';
    return false;
  }

  // 6. Get result
  center = gaussianpeak->centre();
  height = gaussianpeak->height();
  double fwhm = gaussianpeak->fwhm();

  return fwhm > 0.0;
}
コード例 #6
0
    void Test3dBathIntracellularStimulation()
    {
        HeartConfig::Instance()->SetSimulationDuration(1);  //ms
        HeartConfig::Instance()->SetOutputDirectory("BidomainBath3d");
        HeartConfig::Instance()->SetOutputFilenamePrefix("bidomain_bath_3d");

        c_vector<double,3> centre;
        centre(0) = 0.05;
        centre(1) = 0.05;
        centre(2) = 0.05;
        BathCellFactory<3> cell_factory(-2.5e7, centre); // stimulates x=0.05 node

        BidomainProblem<3> bidomain_problem( &cell_factory, true );

        TetrahedralMesh<3,3> mesh;
        mesh.ConstructRegularSlabMesh(0.01, 0.1, 0.1, 0.1);

        // Set everything outside a central sphere (radius 0.4) to be bath
        for (unsigned i=0; i<mesh.GetNumElements(); i++)
        {
            double x = mesh.GetElement(i)->CalculateCentroid()[0];
            double y = mesh.GetElement(i)->CalculateCentroid()[1];
            double z = mesh.GetElement(i)->CalculateCentroid()[2];
            if (sqrt((x-0.05)*(x-0.05) + (y-0.05)*(y-0.05) + (z-0.05)*(z-0.05)) > 0.04)
            {
                mesh.GetElement(i)->SetAttribute(HeartRegionCode::GetValidBathId());
            }
        }

        bidomain_problem.SetMesh(&mesh);
        bidomain_problem.Initialise();

        bidomain_problem.Solve();

        Vec sol = bidomain_problem.GetSolution();
        ReplicatableVector sol_repl(sol);

        // test V = 0 for all bath nodes
        for (unsigned i=0; i<mesh.GetNumNodes(); i++)
        {
            if (HeartRegionCode::IsRegionBath( mesh.GetNode(i)->GetRegion() )) // bath
            {
                TS_ASSERT_DELTA(sol_repl[2*i], 0.0, 1e-12);
            }
        }

        // a hardcoded value
        TS_ASSERT_DELTA(sol_repl[2*404], 39.6833, 1e-3);
    }
コード例 #7
0
ファイル: PlayState.cpp プロジェクト: BeastModeSHU/Copter
void PlayState::updatePaused(float delta)
{
	sf::Vector2f centre(p_rtexture_->getView().getCenter());
	centre -= sf::Vector2f(pauseText_.getGlobalBounds().width / 2.f, pauseText_.getGlobalBounds().height / 2.f);
	pauseText_.setPosition(centre);

}
コード例 #8
0
void draw_sec(CHpoints *p) {
  dpoint c;
  CHpoints *p1,*p2,*p3;
  double radius;
  
  if ((length2(before(p)->node,p->node) > 
       length2(p->node,next(p)->node)) &&
      (length2(before(p)->node,p->node) > 
       length2(before(p)->node,next(p)->node)))
    p2=next(p);  /* the angle at next(p) is the biggest */
  else if ((length2(p->node,next(p)->node) > 
	    length2(before(p)->node,next(p)->node)) &&
	   (length2(p->node,next(p)->node) > 
	    length2(p->node,before(p)->node)))
    p2=before(p); /* the angle at before(p) is the biggest */
  else
    p2=p; /* the angle at p is the biggest */
  p1=before(p2);
  p3=next(p2);

  if (angle(p1,p2,p3)<0) {
    c.x=(midpoint(p1->node,p3->node)).x;      /* center is midpoint of */
    c.y=(midpoint(p1->node,p3->node)).y;      /* p1 and p3             */
    radius=sqrt((double)length2(p1->node,p3->node))/2.00;    
  }
  else {
    c=centre(p1->node,p2->node,p3->node);
    radius=sqrt((double)radius2(p->node,c));
  }
  printf("The center is (%d,%d)\n",(int)c.x,(int)c.y);
  printf("The radius is %9.2f\n",radius);
}	
コード例 #9
0
ファイル: memfilt.cpp プロジェクト: ABratovic/open-watcom-v2
void MemberFilterDlg::initialize()
//--------------------------------
{
    setSystemFont( FALSE );
    rescale();
    move( frame().r );
    centre();

    _inheritGroup = new WGroupBox(      this, _inheritGroupR.r,  _inheritGroupR.t );
    _bttns._none = new WRadioButton(    this, _noneR.r,          _noneR.t, RStyleGroupFirst );
    _bttns._visible = new WRadioButton( this, _visibleR.r,       _visibleR.t );
    _bttns._all = new WRadioButton(     this, _allR.r,           _allR.t, RStyleGroupLast );

    _accessGroup = new WGroupBox(       this, _accessGroupR.r,   _accessGroupR.t );
    _public = new WCheckBox(            this, _publicR.r,        _publicR.t );
    _protected = new WCheckBox(         this, _protectedR.r,     _protectedR.t );
    _private = new WCheckBox(           this, _privateR.r,       _privateR.t );

    _memberGroup = new WGroupBox(       this, _memberGroupR.r,   _memberGroupR.t );
    _variables = new WCheckBox(         this, _variablesR.r,     _variablesR.t );
    _varStatic = new WCheckBox(         this, _varStaticR.r,    _varStaticR.t );
    _functions = new WCheckBox(         this, _functionsR.r,     _functionsR.t );
    _virtual = new WCheckBox(           this, _virtualR.r,       _virtualR.t );
    _funcStatic = new WCheckBox(        this, _funcStaticR.r,    _funcStaticR.t );

    _variables->onClick( this, (cbw) &MemberFilterDlg::varOrFuncPushed );
    _functions->onClick( this, (cbw) &MemberFilterDlg::varOrFuncPushed );

    _okButton = new WDefPushButton( this, _okButtonR.r,      _okButtonR.t );
    _defaultButton = new WPushButton(   this, _defaultButtonR.r, _defaultButtonR.t );
    _cancelButton = new WPushButton(    this, _cancelButtonR.r,  _cancelButtonR.t );


    _inheritGroup->show();
    _bttns._none->show();
    _bttns._visible->show();
    _bttns._all->show();
    _accessGroup->show();
    _public->show();
    _protected->show();
    _private->show();
    _memberGroup->show();
    _variables->show();
    _varStatic->show();
    _functions->show();
    _virtual->show();
    _funcStatic->show();
    _okButton->show();
    _defaultButton->show();
    _cancelButton->show();

    _okButton->onClick(      this, (cbw) MemberFilterDlg::okButton );
    _defaultButton->onClick( this, (cbw) MemberFilterDlg::defaultButton );
    _cancelButton->onClick(  this, (cbw) MemberFilterDlg::cancelButton );

    _bttns._none->setFocus();

    setValues( _current );
    show();
}
コード例 #10
0
ファイル: querycfg.cpp プロジェクト: ABratovic/open-watcom-v2
void QueryConfig::initialize()
//----------------------------
{
    int i;
    OptionManager * optMgr = WBRWinBase::optManager();

    setSystemFont( FALSE );
    rescale();
    move( frame().r );
    centre();

    _symText =      new WText( this, _symTextR.r, _symTextR.t );
    _symName =      new WCommandList( this, _symNameR.r, NULL );

    _symText->show();
    _symName->show();

    _matchCase =    new WCheckBox( this, _matchCaseR.r, _matchCaseR.t );
    _wholeWord =    new WCheckBox( this, _anchoredR.r, _anchoredR.t );
    _useRX =        new WCheckBox( this, _useRXR.r, _useRXR.t );
    _cfgRegexp =    new WPushButton( this, _cfgRegexpR.r, _cfgRegexpR.t );

    _matchCase->show();
    _wholeWord->show();
    _useRX->show();

    _matchCase->setCheck( !optMgr->getIgnoreCase() );
    _wholeWord->setCheck( optMgr->getWholeWord() );
    _useRX->setCheck( optMgr->getUseRX() );
    _useRX->onClick( this, (cbw) &QueryConfig::useRXClicked );
    _wholeWord->enable( !optMgr->getUseRX() );

    _ok =           new WDefPushButton( this, _searchR.r, _searchR.t );
    _cancel =       new WPushButton( this, _cancelR.r, _cancelR.t );
    _filters =      new WPushButton( this, _filtersR.r, _filtersR.t );
    _help =         new WPushButton( this, _helpR.r, _helpR.t );

    _ok->show();
    _cancel->show();
    _filters->show();
    _cfgRegexp->show();
    _help->show();

    _cfgRegexp->enable( optMgr->getUseRX() );

    _ok->onClick(           this, (cbw) &QueryConfig::okButton );
    _cancel->onClick(       this, (cbw) &WDialog::cancelButton );
    _filters->onClick(      this, (cbw) &QueryConfig::filtersButton );
    _cfgRegexp->onClick(    this, (cbw) &QueryConfig::cfgRXButton );
    _help->onClick(         this, (cbw) &QueryConfig::helpButton );

    for( i = 0; i < _searchStrings->count(); i +=1 ) {
        _symName->insertString( ((WString *)(*_searchStrings)[ i ] )->gets(),
                                0 );
    }

    _symName->setFocus();

    show();
}
コード例 #11
0
ファイル: graphics.cpp プロジェクト: Alyanorno/Message-system
void Graphic::Initialize()
{
	SDL_Init( SDL_INIT_VIDEO );

	SDL_SetVideoMode( 800, 600, 0, SDL_OPENGL | SDL_HWSURFACE );
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

	GLint major, minor;
	glGetIntegerv(GL_MAJOR_VERSION, &major);
	glGetIntegerv(GL_MINOR_VERSION, &minor);
	std::cout
		<< "OpenGL on "
		<< glGetString(GL_VENDOR)
		<< glGetString(GL_RENDERER) << '\n';
	std::cout
		<< "OpenGL version supported "
		<< glGetString(GL_VERSION) << '\n';
	std::cout
		<< "GLSL version supported "
		<< glGetString(GL_SHADING_LANGUAGE_VERSION) << '\n';
	std::cout
		<< "Will now set GL to version "
		<< major << minor << '\n';

	
	glHint( GL_POINT_SMOOTH_HINT,GL_NICEST );
	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

	glEnable( GL_DEPTH_TEST ); 
	glEnable( GL_TEXTURE_2D );
	glEnable( GL_LINE_SMOOTH );
	glShadeModel( GL_SMOOTH );

	glViewport (0, 0, 800, 600);
	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
	glDepthFunc(GL_LEQUAL);

	glMatrixMode (GL_PROJECTION);
	glFrustum (-1.0, 1.0, -1.0, 1.0, 1.5, 1000.0);
	glMatrixMode (GL_MODELVIEW);

	glEnableClientState( GL_VERTEX_ARRAY );
	glEnableClientState( GL_NORMAL_ARRAY );
	glEnableClientState( GL_TEXTURE_COORD_ARRAY );


	glm::vec3 eye(0.0f, 0.0f, 2.0f), centre(0, 0, -1.0f), up(0.0f, 1.0f, 0.0f);
	viewMatrix = glm::lookAt(eye, centre, up);


	GLuint vertexShader = LoadShader( "shader.vertex", Vertex );
	GLuint fragmentShader = LoadShader( "shader.fragment", Fragment );

	GLuint shaderProgram = glCreateProgram();

	glAttachShader( shaderProgram, vertexShader );
	glAttachShader( shaderProgram, fragmentShader );

	glLinkProgram( shaderProgram );
}
コード例 #12
0
ファイル: winpdlg.cpp プロジェクト: Ukusbobra/open-watcom-v2
void WInputDialog::initialize() {
/*******************************/

    WPoint avg;
    WPoint max;
    textMetrics( avg, max );
    int sp = max.x();

    int x = WSystemMetrics::dialogFrameWidth();
    int y = WSystemMetrics::dialogFrameHeight();

    int p_w = 0;
    int p_h = 0;
    updateExtents( _promptText, &p_w, &p_h );
    p_w += avg.x() / 2;
    p_h += avg.y() / 2;
    int r_w = 32 * avg.x();
    int r_h = max.y() + 2*max.y() / 3;
    updateExtents( *_reply, &r_w, &r_h );

    _prompt = new WText( this, WRect( x, y + (r_h - p_h)/2, p_w, p_h ), _promptText );
    _prompt->show();
    _input = new WEditBox( this, WRect( x + p_w + sp, y, r_w, r_h ), *_reply );
    _input->show();
    y += p_h + max.y();

    int b_w = 0;
    int b_h = 0;
    updateExtents( BrowseText, &b_w, &b_h );
    updateExtents( CancelText, &b_w, &b_h );
    updateExtents( OKText, &b_w, &b_h );
    b_w += avg.x() * 2;
    b_h += avg.y() / 2;
    WDefPushButton *bOk = new WDefPushButton( this, WRect( x, y, b_w, b_h ),
                                              OKText );
    bOk->onClick( this, (cbw)&WInputDialog::okButton );
    bOk->show();
    x += b_w + max.x();

    WPushButton *bCancel = new WPushButton( this, WRect( x, y, b_w, b_h ),
                                            CancelText );
    bCancel->onClick( this, (cbw)&WInputDialog::cancelButton );
    bCancel->show();
    x += b_w + max.x();

    if( _browseDialog ) {
        WPushButton *bBrowse = new WPushButton( this,
                                                WRect( x, y, b_w, b_h ),
                                                BrowseText );
        bBrowse->onClick( this, (cbw)&WInputDialog::browseButton );
        bBrowse->show();
    }

    shrink();
    centre();

    _input->select();
    _input->setFocus();
    show();
}
コード例 #13
0
ファイル: Terrain.cpp プロジェクト: azzogat/KT_mamba
void Terrain::HighLightPosition( float x,float z,float radius ) {

  if (x != lastx || z != lastz) {
	  int centerX = x*(m_heightField.xDim-1);
	  int centerZ = z*(m_heightField.zDim-1);
	
	
	  float radiusInFiled = m_heightField.xDim * radius;
	  ofVec2f vecToPoint;
	  ofVec2f centre(centerX,centerZ);
	
	 // colorBuffer[(centerZ*m_heightField.xDim)+centerX] = ofVec3f(1,0,0);
	
	  for (int i = 0; i < m_heightField.xDim; ++i) {
	    for (int j = 0; j < m_heightField.zDim; ++j) {
	
	      vecToPoint = centre - ofVec2f(i,j);
	      float d = vecToPoint.length();
	      float normD = (1.0f-(d/radiusInFiled));
	
	      colorBuffer[(j*m_heightField.xDim)+i] = d < radiusInFiled ? ofVec3f(normD,0,0) : ofVec3f(0,0,0);
	    }
	  }

    lastx = x;
    lastz = z;

    isColorDirty = true;
  }
  


}
コード例 #14
0
ファイル: Terrain.cpp プロジェクト: azzogat/KT_mamba
void Terrain::AdjustHeight( float diff,float x,float z,float radius ) {
  if (diff != 0) {
    isGeomDirty = true;
    int centerX = x*(m_heightField.xDim-1);
    int centerZ = z*(m_heightField.zDim-1);


    float radiusInFiled = m_heightField.xDim * radius;
    ofVec2f vecToPoint;
    ofVec2f centre(centerX,centerZ);

    for (int i = 0; i < m_heightField.xDim; ++i) {
      for (int j = 0; j < m_heightField.zDim; ++j) {

        vecToPoint = centre - ofVec2f(i,j);
        float d = vecToPoint.length();

        if (d < radiusInFiled) {
          float normD = (1.0f-(d/radiusInFiled));

          float finalDiff = sinf(normD)*diff;
          m_heightField.values[i][j] += finalDiff;
       }
      }
    }
  }
}
コード例 #15
0
    void TestCellKillersOutputParameters()
   {
       std::string output_directory = "TestSloughingCellKillersOutputParameters";
       OutputFileHandler output_file_handler(output_directory, false);

       // Test with SloughingCellKiller
       SloughingCellKiller<2> sloughing_cell_killer(NULL, 20.0, true, 10.0);
       TS_ASSERT_EQUALS(sloughing_cell_killer.GetIdentifier(), "SloughingCellKiller-2");

       out_stream sloughing_cell_killer_parameter_file = output_file_handler.OpenOutputFile("sloughing_results.parameters");
       sloughing_cell_killer.OutputCellKillerParameters(sloughing_cell_killer_parameter_file);
       sloughing_cell_killer_parameter_file->close();

       std::string sloughing_cell_killer_results_dir = output_file_handler.GetOutputDirectoryFullPath();
       FileComparison( sloughing_cell_killer_results_dir + "sloughing_results.parameters", "crypt/test/data/TestSloughingCellKillers/sloughing_results.parameters").CompareFiles();

       // Test with RadialSloughingCellKiller
       c_vector<double,2> centre(2);
       centre[0] = 0.1;
       centre[1] = 0.2;
       double radius = 0.4;
       RadialSloughingCellKiller radial_cell_killer(NULL, centre, radius);
       TS_ASSERT_EQUALS(radial_cell_killer.GetIdentifier(), "RadialSloughingCellKiller");

       out_stream radial_cell_killer_parameter_file = output_file_handler.OpenOutputFile("radial_results.parameters");
       radial_cell_killer.OutputCellKillerParameters(radial_cell_killer_parameter_file);
       radial_cell_killer_parameter_file->close();

       std::string radial_cell_killer_results_dir = output_file_handler.GetOutputDirectoryFullPath();
       FileComparison( radial_cell_killer_results_dir + "radial_results.parameters", "crypt/test/data/TestSloughingCellKillers/radial_results.parameters").CompareFiles();
   }
コード例 #16
0
ファイル: vabout.cpp プロジェクト: ABratovic/open-watcom-v2
void VAbout::initialize()
{
    int fw = WSystemMetrics::dialogFrameWidth();
    int fh = WSystemMetrics::dialogFrameHeight();
    int wid = 0;
    int yoff = fh;
    for( int i=0; _viperDesc[i] != NULL; i++ ) {
        int w = getTextExtentX( _viperDesc[i] );
        int h = getTextExtentY( _viperDesc[i] );
        if( w > 0 ) {
            if( wid < w ) wid = w;
            WText* t1 = new WText( this, WRect(fw, yoff, w, h), _viperDesc[i] );
//          WText* t1 = new WText( this, WRect(fw, yoff, w, h), _viperDesc[i], TextStyleCentre );
            yoff += h * 5/4;
            t1->show();
        }
    }
    wid += fw * 2;

    static const char ok[] = { "OK" };
    int w = getTextExtentX( ok ) * 3;
    int h = getTextExtentY( ok ) * 3/2;
    int xoff = (wid - w) / 2;
    WDefPushButton* bOk = new WDefPushButton( this, WRect( xoff, yoff, w, h), "OK" );
    yoff += h * 5/4;
    bOk->onClick( this, (cbw)&VAbout::okButton );
    bOk->show();

    shrink();
    centre();

    show();
    bOk->setFocus();
}
コード例 #17
0
TEST_F(BodySurfaceDynamicFrameTest, Serialization) {
  serialization::DynamicFrame message;
  big_frame_->WriteToMessage(&message);

  EXPECT_TRUE(message.HasExtension(
      serialization::BodySurfaceDynamicFrame::extension));
  auto const extension = message.GetExtension(
      serialization::BodySurfaceDynamicFrame::extension);
  EXPECT_TRUE(extension.has_centre());
  EXPECT_EQ(0, extension.centre());

  auto const read_big_frame =
      DynamicFrame<ICRFJ2000Equator, BigSmallFrame>::ReadFromMessage(
          ephemeris_.get(), message);
  EXPECT_THAT(read_big_frame, Not(IsNull()));

  Instant const t = t0_ + period_;
  DegreesOfFreedom<BigSmallFrame> const point_dof =
      {Displacement<BigSmallFrame>({10 * Metre, 20 * Metre, 30 * Metre}) +
           BigSmallFrame::origin,
       Velocity<BigSmallFrame>({3 * Metre / Second,
                                2 * Metre / Second,
                                1 * Metre / Second})};
  EXPECT_EQ(big_frame_->GeometricAcceleration(t, point_dof),
            read_big_frame->GeometricAcceleration(t, point_dof));
}
コード例 #18
0
ファイル: Rect.cpp プロジェクト: AD87/Super-Smash-TV
Rect Rect::scale(float number)const{
	Vec2f centre((m_maxX + m_minX)*0.5f, (m_maxY + m_minY)*0.5f);
	float w = m_maxX - m_minX;
	float h = m_maxY - m_minY;
	return Rect(centre.x - w*0.5f*number, centre.x + w*0.5f*number,
		centre.y - h*0.5f*number, centre.y + h*0.5f*number);
}
コード例 #19
0
ファイル: Ui.cpp プロジェクト: rohandas36/FlowuUiN
void updateState(GLFWwindow* window, Grid* fluid,
				Vector3* camerapos,Vector3* camera_z,Vector3* camera_y,
				Vector3* lightPos){

	static double lastTime = glfwGetTime();
	double currentTime = glfwGetTime();

	glfwPollEvents();

	double xpos, ypos;
	glfwGetCursorPos(window, &xpos, &ypos);

	xpos -= 1366/2;
	ypos -= 768/2;

	xpos/=100;
	ypos/=100;
	Vector3 centre(0,0,2),current(xpos,ypos,sqrt(4-xpos*xpos-ypos*ypos));
	Matrix4 rotMat;

	int state = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL );
	if((centre*current).mod()>0.005 ){
		Vector3 rotation_Goal=centre*current*300;
		Matrix4 basisTransform(-*camera_z,*camera_y,Matrix4::BASIS);
		rotation_Goal=(basisTransform*Vector4(rotation_Goal,0)).xyz();
		rotMat = 	Matrix4(Vector3(50,50,50),Matrix4::TRANSLATE)*
					Matrix4(rotation_Goal,Vector3(1.25,3.4,5.4),Matrix4::BASIS)*
					Matrix4(rotation_Goal ,Matrix4::ROTATION_Z)*
					Matrix4(rotation_Goal,Vector3(1.25,3.4,5.4))*
					Matrix4(Vector3(-50,-50,-50),Matrix4::TRANSLATE);
		fluid->Model = rotMat*fluid->Model;
	}
	glfwSetCursorPos(window, 1366/2, 768/2);
}
コード例 #20
0
ファイル: main_model.cpp プロジェクト: reuk/wayverb
project::project(const std::string& fpath)
        : scene_data_{is_project_file(fpath) ? compute_model_path(fpath)
                                             : fpath}
        , needs_save_{!is_project_file(fpath)} {
    //  First make sure default source and receiver are in a sensible position.
    const auto aabb =
            wayverb::core::geo::compute_aabb(get_scene_data().get_vertices());
    const auto c = centre(aabb);

    (*persistent.sources())[0]->set_position(c);
    (*persistent.receivers())[0]->set_position(c);

    //  Set up surfaces.
    const auto& surface_strings = scene_data_.get_scene_data()->get_surfaces();
    *persistent.materials() = wayverb::combined::model::materials_from_names<1>(begin(surface_strings),
                                                      end(surface_strings));

    //  If there's a config file, we'll just overwrite the state we just set,
    //  but that's probably fine.
    if (is_project_file(fpath)) {
        const auto config_file = project::compute_config_path(fpath);

        //  load the config
        std::ifstream stream{config_file};
        cereal::JSONInputArchive{stream}(persistent);
    }

    persistent.connect([&](auto&) { needs_save_ = true; });
}
コード例 #21
0
void NewDBRFile::initialize()
//--------------------------
{
    setSystemFont( false );
    rescale();
    move( frame().r );
    centre();

    _browsefileGroup =   new WGroupBox(      this, _browsefileGroupR.r,   _browsefileGroupR.t );
    _fileEdit =          new WEditBox(       this, _fileEditR.r,          _fileEditR.t );
    _okButton =          new WDefPushButton( this, _okButtonR.r,          _okButtonR.t );
    _browseFilesButton = new WPushButton(    this, _browseFilesButtonR.r, _browseFilesButtonR.t );
    _cancelButton =      new WPushButton(    this, _cancelButtonR.r,      _cancelButtonR.t );

    _browsefileGroup->show();
    _fileEdit->show();
    _okButton->show();
    _browseFilesButton->show();
    _cancelButton->show();

    _okButton->onClick(          this, (cbw) NewDBRFile::okButton );
    _browseFilesButton->onClick( this, (cbw) NewDBRFile::filesButton );
    _cancelButton->onClick(      this, (cbw) NewDBRFile::cancelButton );

    _fileEdit->setFocus();

    show();
}
TEST_F(BodyCentredNonRotatingDynamicFrameTest, Serialization) {
  serialization::DynamicFrame message;
  small_frame_->WriteToMessage(&message);

  EXPECT_TRUE(message.HasExtension(
      serialization::BodyCentredNonRotatingDynamicFrame::extension));
  auto const extension = message.GetExtension(
      serialization::BodyCentredNonRotatingDynamicFrame::extension);
  EXPECT_TRUE(extension.has_centre());
  EXPECT_EQ(1, extension.centre());

  auto const read_small_frame =
      DynamicFrame<ICRS, Small>::ReadFromMessage(message, ephemeris_.get());
  EXPECT_THAT(read_small_frame, Not(IsNull()));

  Instant const t = t0_ + period_;
  DegreesOfFreedom<Small> const point_dof =
      {Displacement<Small>({10 * Metre, 20 * Metre, 30 * Metre}) +
           Small::origin,
       Velocity<Small>({3 * Metre / Second,
                        2 * Metre / Second,
                        1 * Metre / Second})};
  EXPECT_EQ(small_frame_->GeometricAcceleration(t, point_dof),
            read_small_frame->GeometricAcceleration(t, point_dof));
}
コード例 #23
0
ファイル: fuzzy.cpp プロジェクト: tnaran/fuzzygen
float FuzzyVariable::right(int crispValue, int median, int deviation)
{
	if( crispValue >= median )
		return 1.0f;
	else
		return centre(crispValue, median, deviation);
}
コード例 #24
0
/**
 *	This is the constructor for SphereVectorGenerator.
 *
 * 	@param Centre		The centre of the sphere.
 * 	@param MaxRadius	The radius of the sphere.
 * 	@param MinRadius	The radius of the hole in the centre of the sphere.
 */
SphereVectorGenerator::SphereVectorGenerator( const Vector3 &Centre,
		float MaxRadius,
		float MinRadius )
{
	centre(Centre);
	maxRadius(MaxRadius);
	minRadius(MinRadius);
}
コード例 #25
0
ファイル: PlayState.cpp プロジェクト: BeastModeSHU/Copter
void PlayState::updateWinScreen(float delta)
{
	sf::Vector2f centre(p_rtexture_->getView().getCenter());
	centre -= sf::Vector2f(winText_.getGlobalBounds().width / 2.f, winText_.getGlobalBounds().height / 2.f);
	winText_.setPosition(centre);
	scoreText_.setString("Your score was : " + std::to_string((int)score_));
	scoreText_.setPosition(centre.x + 20, centre.y + 150);
}
コード例 #26
0
void DIALOG_CREATE_ARRAY::calculateCircularArrayProperties()
{
    VECTOR2I centre( m_hCentre.GetValue(), m_vCentre.GetValue() );

    // Find the radius, etc of the circle
    centre -= m_originalItemPosition;

    m_circRadius.SetValue( int( centre.EuclideanNorm() ) );
}
コード例 #27
0
float circle_phi(const Vec2f& pos) {
   Vec2f centre(0.5f,0.75f);
   float rad = 0.1f;
   Vec2f centre1(0.4f, 0.3f);
   float rad1 = 0.15f;
   float phi0 = dist(centre, pos) - rad;
   float phi1 = dist(centre1, pos) - rad1;
   return min(phi0,phi1);
}
コード例 #28
0
	static void PlaneCollisionCollideCallbackDescrete (NewtonUserMeshCollisionCollideDesc* const collideDesc)
	{
		dInfinitePlane* const me = (dInfinitePlane*) collideDesc->m_userData;

		dVector p0 (collideDesc->m_boxP0[0], collideDesc->m_boxP0[1], collideDesc->m_boxP0[2], 0.0f);
		dVector p1 (collideDesc->m_boxP1[0], collideDesc->m_boxP1[1], collideDesc->m_boxP1[2], 0.0f);
		dVector suportVertex ((me->m_plane.m_x > 0.0f) ? p0.m_x : p1.m_x, (me->m_plane.m_y > 0.0f) ? p0.m_y : p1.m_y, (me->m_plane.m_z > 0.0f) ? p0.m_z : p1.m_z);

		dFloat dist = me->m_plane.DotProduct3(suportVertex) + me->m_plane.m_w;
		if (dist < 0.25f) {
			// calculate the aabb center
			dVector centre ((p1 + p0).Scale (0.5f));

			//find the projection of center point over the plane
			dFloat t = - (me->m_plane.DotProduct3(centre) + me->m_plane.m_w);
			centre += me->m_plane.Scale (t);

			//know calculate the scale factor
			dVector size (p1 - p0);
			dFloat s = dMax(size.m_x, dMax (size.m_y, size.m_z));

			dInt32 threadNumber = collideDesc->m_threadNumber;

			// initialize the callback data structure
#ifdef PASS_A_QUAD
			collideDesc->m_faceCount = 1;
#else
			collideDesc->m_faceCount = 2;
#endif
			collideDesc->m_vertexStrideInBytes = sizeof (dVector);
			collideDesc->m_faceIndexCount = &me->m_faceIndices[threadNumber][0];
			collideDesc->m_faceVertexIndex = &me->m_indexArray[threadNumber][0];
			collideDesc->m_vertex = &me->m_collisionVertex[threadNumber][0][0];
			dVector* const polygon = &me->m_collisionVertex[threadNumber][0];
			for (int i = 0; i < 4; i ++) {
				polygon[i] = centre + me->m_unitSphape[i].Scale (s);
			}
			// save face normal
			polygon[4] =  me->m_plane;

			// show debug display info
			if (DebugDisplayOn()) {
				dMatrix matrix;
				dVector face[64];

				NewtonBodyGetMatrix (collideDesc->m_polySoupBody, &matrix[0][0]);
				matrix.TransformTriplex (&face[0].m_x, sizeof (dVector), &polygon[0].m_x, sizeof (dVector), 4);

				NewtonWorld* const world = NewtonBodyGetWorld (collideDesc->m_polySoupBody);
				// critical section lock
				NewtonWorldCriticalSectionLock (world, threadNumber);
				//DebugDrawPolygon (4, &face[0]);
				// unlock the critical section
				NewtonWorldCriticalSectionUnlock (world);
			}
		}
	}
コード例 #29
0
CHpoints *maximize_radius_and_angle(CHpoints *S) {
  CHpoints *p1,*p2,*p3;
  key key1,key2;
  p2=CHdelete_max(&CHSplaytree);
  p1=before(p2);
  p3=next(p2);
  key1.radius=radius2(p1->node,
		      centre(before(p1)->node,p1->node,p2->node));
  key1.angle=angle(before(p1),p1,p2);
  key1.number=p1->number;
  CHdelete(&CHSplaytree,key1); /* delete before(p) */
  key2.radius=radius2(p3->node,
		      centre(p2->node,p3->node,next(p3)->node));
  key2.angle=angle(p2,p3,next(p3));
  key2.number=p3->number;
  CHdelete(&CHSplaytree,key2); /* delete next(p) */
  return p2;
}
コード例 #30
0
ファイル: fuzzy.cpp プロジェクト: tnaran/fuzzygen
float FuzzyVariable::left(int crispValue, int median, int deviation)
{
	if( crispValue <= median )
		return 1.0f;
	else
	{
		return centre(crispValue, median, deviation);
	}
}