本文整理汇总了C++中qPow函数的典型用法代码示例。如果您正苦于以下问题:C++ qPow函数的具体用法?C++ qPow怎么用?C++ qPow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qPow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filterAvailableUSDAmountValue
void Exchange_Bitstamp::filterAvailableUSDAmountValue(double *amount)
{
double decValue=mainWindow.getValidDoubleForPercision((*amount)*mainWindow.floatFee,baseValues.currentPair.priceDecimals,false);
decValue+=qPow(0.1,qMax(baseValues.currentPair.priceDecimals,1));
*amount=mainWindow.getValidDoubleForPercision((*amount)-decValue,baseValues.currentPair.currBDecimals,false);
}
示例2: qPow
void ImageView::wheelEvent(QWheelEvent *event)
{
qreal factor = qPow(Constants::DEFAULT_SCALE_FACTOR, event->delta() / 240.0);
doScale(factor);
event->accept();
}
示例3: return
qreal Curve::calcYDerivative(qreal t)
{
return (t * t + 2 * t - 1) / qPow(t + 1, 2.);
}
示例4: qDebug
void MainWindow::tick()
{
if((pig_count==0&&bird_count==6) || score==33000)
{
qDebug() << "pig_count : " << pig_count;
qDebug() << "bird_count : " << bird_count;
qDebug() << "score : " << score;
showResult();
}
ui->lcdNumber->display(score);
ui->lcdNumber_2->display(pig_count);
ui->lcdNumber_3->display(6-bird_count);
if(shot)
{
CD = (*Bit)->available;
b2Vec2 speed = (*Bit)->Body->GetLinearVelocity();
VB = qSqrt(qPow(speed.x,2)+qPow(speed.y,2));
b2Vec2 X = (*Bit)->Body->GetPosition();;
if((X.y>120 || X.x<-20) || X.x>100)
outer = true;
if((VB==0 || outer) && bird_count == 2)
{
bird2 = new Bird(2,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS, &timer, QPixmap(":/bird/img/Angry Birds Seasons/angry-bird-yellow-icon.png"), world, scene);
BIRD.push_back(bird2);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 3)
{
bird3 = new Bird(3,6.8f, 10.7f,BIRD_DENSITY*4, 1.5, &timer, QPixmap(":/bird/img/Angry Birds Seasons/BLOCK_STEEL_BALL.png"), world, scene);
BIRD.push_back(bird3);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 4)
{
bird4 = new Bird(4,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS*1.75, &timer, QPixmap(":/bird/img/Angry Birds Seasons/BIRD_GREY_YELL.png"), world, scene);
BIRD.push_back(bird4);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 5)
{
bird5 = new Bird(5,7.1f, 10.9f,BIRD_DENSITY, BIRD_RADIUS*2, &timer, QPixmap(":/bird/img/Angry Birds Seasons/TA.png"), world, scene);
BIRD.push_back(bird5);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
}
else if((VB==0 || outer) && bird_count == 6)
{
bird6 = new Bird(6,6.8f, 10.7f,BIRD_DENSITY, BIRD_RADIUS, &timer, QPixmap(""), world, scene);
BIRD.push_back(bird6);
delete (*Bit);
BIRD.erase(Bit);
shot = false;
newed = true;
outer = false;
showResult();
}
}
for(it = WOOD.begin(); it!= WOOD.end(); ++it)
{
if((*it)->death)
{
delete (*it);
WOOD.erase(it);
score += 2000;
//qDebug() << score;
}
}
for(it = PIG.begin(); it!= PIG.end(); ++it)
{
if((*it)->death)
{
delete (*it);
PIG.erase(it);
score += 5000;
--pig_count;
//qDebug() << score;
}
}
world->Step(1.0/60.0, 6, 2);
scene->update();
}
示例5: QLineF
QLineF item_rectangles::snapLine(QLineF mouseLine, QSizeF Box)
{
qreal a = mouseLine.angle();
qreal relA = QLineF(0,0, Box.width(), -Box.height()).angle();
qreal tarA = 0;
bool isDiagonal=false;
bool isVertical=false;
if(a == 0)
{
tarA = a;
goto skipAngleCalculate;
}
else if(a == 90)
{
tarA = a;
isVertical=true;
goto skipAngleCalculate;
}
else if(a == 180)
{
tarA = a;
goto skipAngleCalculate;
}
else if(a == 270)
{
tarA = a;
isVertical=true;
goto skipAngleCalculate;
}
//Calculating target angle
if(a <= 90){
if(a < relA/2){
tarA = 0;
}else if(a <= 90-(90-relA)/2 ){
tarA = relA;
isDiagonal=true;
}else{
tarA = 90;
isVertical=true;
}
}else if(a <= 180){
if(a <= 90+(90-relA)/2 ){
tarA = 90;
isVertical=true;
}else if(a <= 180-relA/2 ){
tarA = 180-relA;
isDiagonal=true;
}else{
tarA = 180;
}
}else if(a <= 270){
if(a < 180+(relA/2)){
tarA = 180;
}else if(a <= 270-(90-relA)/2){
tarA = 180+relA;
isDiagonal=true;
}else{
tarA = 270;
isVertical=true;
}
}else{
if(a <= 270+(90-relA)/2 ){
tarA = 270;
isVertical=true;
}else if(a < 360-relA/2){
tarA = 360-relA;
isDiagonal=true;
}else{
tarA = 360;
}
}
skipAngleCalculate:
qreal diagonalSize = qSqrt( qPow(Box.height(),2) + qPow(Box.width(),2) ); //get box diagonal size
qreal Lenght = mouseLine.length() -
((isDiagonal)? qRound(mouseLine.length())%qRound(diagonalSize) //Diagonal
: (isVertical ? qRound(mouseLine.length())%qRound(Box.height()): //Vertical
qRound(mouseLine.length())%qRound(Box.width()) ) ); //Horizontal
return QLineF::fromPolar(Lenght,tarA).translated(mouseLine.p1());;
}
示例6: qwtPowInterval
static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval )
{
return QwtInterval( qPow( base, interval.minValue() ),
qPow( base, interval.maxValue() ) );
}
示例7: b2Vec2
bool MainWindow::eventFilter(QObject *, QEvent *event)
{
if(pressed && event->type() == QEvent::MouseButtonRelease)
{
arrow->setVisible(false);
Force_pos = static_cast<QMouseEvent*>(event)->pos();
if(pressed && bird_count!=3 && bird_count!=5)
shootbird->play();
pressed = false;
b2Vec2 linearV = b2Vec2((clicked_point.x()-Force_pos.x())/15,(Force_pos.y()-clicked_point.y())/15);
if(bird_count == 1)
{
bird1->setLinearVelocity(linearV);
bird1->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
/*BIRD.push_back(bird1);
Bit = BIRD.begin();*/
newed = false;
}
else if(bird_count == 2 && newed)
{
bird2->setLinearVelocity(linearV);
bird2->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird2);
//++Bit;
newed = false;
}
else if(bird_count == 3 && newed)
{
bird3->setLinearVelocity(linearV);
bird3->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird3);
//++Bit;
newed = false;
}
else if(bird_count == 4 && newed)
{
bird4->setLinearVelocity(linearV);
bird4->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird4);
//++Bit;
newed = false;
}
else if(bird_count == 5 && newed)
{
bird5->setLinearVelocity(linearV);
bird5->Body->SetGravityScale(1);
++bird_count;
shot = true;
skill = true;
//BIRD.push_back(bird5);
//++Bit;
newed = false;
}
}
else if(event->type() == QEvent::MouseMove)
{
//Force_pos = static_cast<QMouseEvent*>(event)->pos();
if(pressed && !BIRD.empty() && !shot && VB == 0)
{
//qDebug() << "ARROW!";
QPointF temp = static_cast<QMouseEvent*>(event)->pos();
arrow->resetTransform();
arrow->setPos(QPointF(50, 400));
arrow->setRotation(qAtan2(-temp.y()+clicked_point.y(), -temp.x()+clicked_point.x())*180/pi);
arrow->setScale(qSqrt(qPow(temp.y()-clicked_point.y(), 2) + qPow(temp.x()-clicked_point.x(), 2))/300);
arrow->setVisible(true);
}
}
return false;
}
示例8: qPow
void QAGC::setFixedGain(float gain) {
mutex.lock();
m_gainFix = qPow(10.0, gain/20.0);
mutex.unlock();
}
示例9: qBound
void OpenAL::setInputGain(qreal dB)
{
gain = qBound(minInGain, dB, maxInGain);
gainFactor = qPow(10.0, (gain / 20.0));
}
示例10: Q_UNUSED
QgsRasterBlock * QgsBrightnessContrastFilter::block( int bandNo, QgsRectangle const & extent, int width, int height )
{
Q_UNUSED( bandNo );
QgsDebugMsg( QString( "width = %1 height = %2 extent = %3" ).arg( width ).arg( height ).arg( extent.toString() ) );
QgsRasterBlock *outputBlock = new QgsRasterBlock();
if ( !mInput )
{
return outputBlock;
}
// At this moment we know that we read rendered image
int bandNumber = 1;
QgsRasterBlock *inputBlock = mInput->block( bandNumber, extent, width, height );
if ( !inputBlock || inputBlock->isEmpty() )
{
QgsDebugMsg( "No raster data!" );
delete inputBlock;
return outputBlock;
}
if ( mBrightness == 0 && mContrast == 0 )
{
QgsDebugMsg( "No brightness changes." );
delete outputBlock;
return inputBlock;
}
if ( !outputBlock->reset( QGis::ARGB32_Premultiplied, width, height ) )
{
delete inputBlock;
return outputBlock;
}
// adjust image
QRgb myNoDataColor = qRgba( 0, 0, 0, 0 );
QRgb myColor;
int r, g, b, alpha;
double f = qPow(( mContrast + 100 ) / 100.0, 2 );
for ( qgssize i = 0; i < ( qgssize )width*height; i++ )
{
if ( inputBlock->color( i ) == myNoDataColor )
{
outputBlock->setColor( i, myNoDataColor );
continue;
}
myColor = inputBlock->color( i );
alpha = qAlpha( myColor );
r = adjustColorComponent( qRed( myColor ), alpha, mBrightness, f );
g = adjustColorComponent( qGreen( myColor ), alpha, mBrightness, f );
b = adjustColorComponent( qBlue( myColor ), alpha, mBrightness, f );
outputBlock->setColor( i, qRgba( r, g, b, alpha ) );
}
delete inputBlock;
return outputBlock;
}
示例11: qPow
qreal MyWidget::yt5(qreal x)
{
return qPow(qExp(1), 2 * x - 1) - 2 * qPow(qExp(1), x) + qExp(1) - 1;
}
示例12: qPow
/*!
Draw the rose
\param painter Painter
\param palette Palette
\param center Center of the rose
\param radius Radius of the rose
\param north Position pointing to north
\param width Width of the rose
\param numThorns Number of thorns
\param numThornLevels Number of thorn levels
\param shrinkFactor Factor to shrink the thorns with each level
*/
void QwtSimpleCompassRose::drawRose(
QPainter *painter,
const QPalette &palette,
const QPointF ¢er, double radius, double north, double width,
int numThorns, int numThornLevels, double shrinkFactor )
{
if ( numThorns < 4 )
numThorns = 4;
if ( numThorns % 4 )
numThorns += 4 - numThorns % 4;
if ( numThornLevels <= 0 )
numThornLevels = numThorns / 4;
if ( shrinkFactor >= 1.0 )
shrinkFactor = 1.0;
if ( shrinkFactor <= 0.5 )
shrinkFactor = 0.5;
painter->save();
painter->setPen( Qt::NoPen );
for ( int j = 1; j <= numThornLevels; j++ )
{
double step = qPow( 2.0, j ) * M_PI / numThorns;
if ( step > M_PI_2 )
break;
double r = radius;
for ( int k = 0; k < 3; k++ )
{
if ( j + k < numThornLevels )
r *= shrinkFactor;
}
double leafWidth = r * width;
if ( 2.0 * M_PI / step > 32 )
leafWidth = 16;
const double origin = north / 180.0 * M_PI;
for ( double angle = origin;
angle < 2.0 * M_PI + origin; angle += step )
{
const QPointF p = qwtPolar2Pos( center, r, angle );
const QPointF p1 = qwtPolar2Pos( center, leafWidth, angle + M_PI_2 );
const QPointF p2 = qwtPolar2Pos( center, leafWidth, angle - M_PI_2 );
const QPointF p3 = qwtPolar2Pos( center, r, angle + step / 2.0 );
const QPointF p4 = qwtPolar2Pos( center, r, angle - step / 2.0 );
QPainterPath darkPath;
darkPath.moveTo( center );
darkPath.lineTo( p );
darkPath.lineTo( qwtIntersection( center, p3, p1, p ) );
painter->setBrush( palette.brush( QPalette::Dark ) );
painter->drawPath( darkPath );
QPainterPath lightPath;
lightPath.moveTo( center );
lightPath.lineTo( p );
lightPath.lineTo( qwtIntersection( center, p4, p2, p ) );
painter->setBrush( palette.brush( QPalette::Light ) );
painter->drawPath( lightPath );
}
}
painter->restore();
}
示例13: qPow
void FeaturesCalculation::calculateTextureParameter(PARAMETR param)
{
float qrt = 0, fabs = 0, thigmaSqr = 0, U = 0;
for(int k = 0; k < seedVect.length(); k++)
{
for(int i=0; i< seedVect[k].GLCM.rows; i++)
for(int j=0; j< seedVect[k].GLCM.cols; j++)
{
if(param == DISSIMILARITY)
{
qrt = qPow(i-j,2);
fabs = qSqrt(qrt);
seedVect[k].dissimilarity += fabs*seedVect[k].GLCM.at<uchar>(i,j);
}
if(param == ENERGY)
{
seedVect[k].energy += qPow(seedVect[k].GLCM.at<uchar>(i,j),2);
}
if(param == ENTROPY)
{
if (seedVect[k].GLCM.at<uchar>(i,j) != 0)
{
// float ln = -qLn(seedVect[k].GLCM.at<uchar>(i,j));
seedVect[k].entropy += -qLn(seedVect[k].GLCM.at<uchar>(i,j)) * seedVect[k].GLCM.at<uchar>(i,j);
}
// printf("ln = %f, char =%d entropy = %f\n", ln, seedVect[k].GLCM.at<uchar>(i,j), seedVect[k].entropy);
}
if(param == HOMOGENEITY)
{
qrt = qPow(i-j,2);
if(qrt != 1)
seedVect[k].homogeneity += (1/(1-qPow(i-j,2)))*seedVect[k].GLCM.at<uchar>(i,j);
}
if(param == CONTRAST)
{
int pixel = seedVect[k].GLCM.at<uchar>(i,j);
float dividing = pixel;
float qrt = qPow(i-j, 2);
float contr = qrt * dividing;
seedVect[k].contrast += contr;
}
if(param == CORRELATION)
{
calculateUandThigma(k, U, thigmaSqr);
seedVect[k].correlation += seedVect[k].GLCM.at<uchar>(i,j)*(i-U)*(j-U) / thigmaSqr;
}
}
if(param == DISSIMILARITY)
seedVect[k].dissimilarity = seedVect[k].dissimilarity / (seedVect[k].countOfPairs);
if(param == HOMOGENEITY)
seedVect[k].homogeneity = seedVect[k].homogeneity / (seedVect[k].countOfPairs);
if(param == CONTRAST)
seedVect[k].contrast = seedVect[k].contrast/(seedVect[k].countOfPairs);
if(param == ENERGY)
seedVect[k].energy = seedVect[k].energy / (seedVect[k].countOfPairs);
if(param == ENTROPY)
seedVect[k].entropy = seedVect[k].entropy / (seedVect[k].countOfPairs);
if(param == CORRELATION)
seedVect[k].correlation = seedVect[k].correlation / (seedVect[k].countOfPairs);
}
}
示例14: new_image
QImage EdgeDetection::gradientMagnitudeImage(QImage *image)
{
QImage new_image(image->size(), QImage::Format_ARGB32_Premultiplied);
// QImage orient_image(image->size(), QImage::Format_ARGB32_Premultiplied);
QList<QPair<QPoint, QPair<int, int> > > x_y_struct;
x_y_struct.append( qMakePair(QPoint(-1,-1), QPair<int,int>(-1, 1) ));
x_y_struct.append( qMakePair(QPoint(-1,0), QPair<int,int>(-2, 0) ));
x_y_struct.append( qMakePair(QPoint(-1,1), QPair<int,int>(-1,-1) ));
x_y_struct.append( qMakePair(QPoint(0,-1), QPair<int,int>(0,2) ));
x_y_struct.append( qMakePair(QPoint(0,0), QPair<int,int>(0,0) ));
x_y_struct.append( qMakePair(QPoint(0,1), QPair<int,int>(0,-2) ));
x_y_struct.append( qMakePair(QPoint(1,-1), QPair<int,int>(1,1) ));
x_y_struct.append( qMakePair(QPoint(1,0), QPair<int,int>(2,0) ));
x_y_struct.append( qMakePair(QPoint(1,1), QPair<int,int>(1, -1) ));
// QList<QPair<QPoint, qreal> > orientations;
// qreal orien_min = 1000;
// qreal orien_max = 0;
// int threshold = QInputDialog::getInteger(0, "Threshold", "Threshold value:", -1, -1, 255);
for( int y=0; y < image->height(); y++ ) {
for( int x=0; x < image->width(); x++ ) {
QPoint point(x,y);
int x_sum = 0;
int x_rsum = 0;
int x_gsum = 0;
int x_bsum = 0;
int y_sum = 0;
int y_rsum = 0;
int y_gsum = 0;
int y_bsum = 0;
//Perform Convolution on X
for (int i=0; i < x_y_struct.size(); i++) {
QPoint offset = x_y_struct.at(i).first;
QPair<int,int> multiplier = x_y_struct.at(i).second;
//Only convolve real pixels
int pixel_x = offset.x() + x;
int pixel_y = offset.y() + y;
QRgb color;
if ( pixel_x < 0 ||
pixel_x >= image->width() ||
pixel_y < 0 ||
pixel_y >= image->height() ) {
color = qRgb(128, 128, 128);
} else {
color = image->pixel(QPoint(pixel_x, pixel_y));
}
int gray_val = qGray(color);
x_sum += gray_val * multiplier.first;
x_rsum += qRed(color) * multiplier.first;
x_gsum += qGreen(color) * multiplier.first;
x_bsum += qBlue(color) * multiplier.first;
y_sum += gray_val * multiplier.second;
y_rsum += qRed(color) * multiplier.second;
y_gsum += qGreen(color) * multiplier.second;
y_bsum += qBlue(color) * multiplier.second;
}
//Gradient
qreal gradient = qSqrt(qPow(x_sum / 8, 2) + qPow(y_sum / 8, 2));
qreal r_gradient = qSqrt(qPow(x_rsum / 8, 2) + qPow(y_rsum / 8, 2));
qreal g_gradient = qSqrt(qPow(x_gsum / 8, 2) + qPow(y_gsum / 8, 2));
qreal b_gradient = qSqrt(qPow(x_bsum / 8, 2) + qPow(y_bsum / 8, 2));
//Orientation
// qreal orientation = qAtan2(y_sum, x_sum);
// if ( orientation < orien_min )
// orien_min = orientation;
// if ( orientation > orien_max )
// orien_max = orientation;
// orientations.append(qMakePair(point, orientation));
//Threshold
// QRgb val;
// if ( threshold < 0 ) {
// val = qRgb(gradient, gradient, gradient);
// } else if ( gradient > threshold ) {
// val = qRgb(255,255,255);
// } else
// val = qRgb(0,0,0);
// new_image.setPixel(point, val);
new_image.setPixel(point, qRgb(r_gradient, g_gradient, b_gradient));
}
}
// for( int i=0; i < orientations.size(); i++ ) {
// QPair<QPoint, qreal> o_pair = orientations.at(i);
// qreal normal = Utility::rangeConvert(orien_max, orien_min, 255, 0, o_pair.second);
// orient_image.setPixel(o_pair.first, qRgb(normal, normal, normal));
// }
return new_image;
}
示例15: base
/*!
\brief Calculate minor/medium ticks for major ticks
\param majorTicks Major ticks
\param maxMinorSteps Maximum number of minor steps
\param stepSize Step size
\param minorTicks Array to be filled with the calculated minor ticks
\param mediumTicks Array to be filled with the calculated medium ticks
*/
void QwtLogScaleEngine::buildMinorTicks(
const QList<double> &majorTicks,
int maxMinorSteps, double stepSize,
QList<double> &minorTicks,
QList<double> &mediumTicks ) const
{
const double logBase = base();
if ( stepSize < 1.1 ) // major step width is one base
{
double minStep = divideInterval( stepSize, maxMinorSteps + 1 );
if ( minStep == 0.0 )
return;
const int numSteps = qRound( stepSize / minStep );
int mediumTickIndex = -1;
if ( ( numSteps > 2 ) && ( numSteps % 2 == 0 ) )
mediumTickIndex = numSteps / 2;
for ( int i = 0; i < majorTicks.count() - 1; i++ )
{
const double v = majorTicks[i];
const double s = logBase / numSteps;
if ( s >= 1.0 )
{
if ( !qFuzzyCompare( s, 1.0 ) )
minorTicks += v * s;
for ( int j = 2; j < numSteps; j++ )
{
minorTicks += v * j * s;
}
}
else
{
for ( int j = 1; j < numSteps; j++ )
{
const double tick = v + j * v * ( logBase - 1 ) / numSteps;
if ( j == mediumTickIndex )
mediumTicks += tick;
else
minorTicks += tick;
}
}
}
}
else
{
double minStep = divideInterval( stepSize, maxMinorSteps );
if ( minStep == 0.0 )
return;
if ( minStep < 1.0 )
minStep = 1.0;
// # subticks per interval
int numTicks = qRound( stepSize / minStep ) - 1;
// Do the minor steps fit into the interval?
if ( qwtFuzzyCompare( ( numTicks + 1 ) * minStep,
stepSize, stepSize ) > 0 )
{
numTicks = 0;
}
if ( numTicks < 1 )
return;
int mediumTickIndex = -1;
if ( ( numTicks > 2 ) && ( numTicks % 2 ) )
mediumTickIndex = numTicks / 2;
// substep factor = base^substeps
const qreal minFactor = qMax( qPow( logBase, minStep ), qreal( logBase ) );
for ( int i = 0; i < majorTicks.count(); i++ )
{
double tick = majorTicks[i];
for ( int j = 0; j < numTicks; j++ )
{
tick *= minFactor;
if ( j == mediumTickIndex )
mediumTicks += tick;
else
minorTicks += tick;
}
}
}
//.........这里部分代码省略.........