本文整理汇总了C++中centre函数的典型用法代码示例。如果您正苦于以下问题:C++ centre函数的具体用法?C++ centre怎么用?C++ centre使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了centre函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: centre
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: display
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;
}
示例3: createChildAlgorithm
/**
* 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 ¢er,
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;
}
示例4: Test3dBathIntracellularStimulation
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);
}
示例5: centre
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);
}
示例6: setSystemFont
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();
}
示例7: setSystemFont
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();
}
示例8: SDL_Init
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 );
}
示例9: textMetrics
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();
}
示例10: centre
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;
}
}
示例11: TestCellKillersOutputParameters
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();
}
示例12: getTextExtentX
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();
}
示例13: TEST_F
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));
}
示例14: centre
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);
}
示例15: updateState
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);
}