当前位置: 首页>>代码示例>>C++>>正文


C++ qSqrt函数代码示例

本文整理汇总了C++中qSqrt函数的典型用法代码示例。如果您正苦于以下问题:C++ qSqrt函数的具体用法?C++ qSqrt怎么用?C++ qSqrt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了qSqrt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qSqrt

void KinematicPoints::SetS5C5()
{
    s[5] = ctheta * (spsi * c[1] - cpsi * s[1]);
    c[5] = delta5 * qSqrt(1 - qPow(s[5], 2));
    fi[5] = qFabs(c[5])>qFabs(s[5])? qAsin(s[5]) : qAcos(c[5]);
    //if(fi[5]!=fi[5]) {emit outOfRange(); return;}

}
开发者ID:justynak,项目名称:ZBR,代码行数:8,代码来源:kinematicpoints.cpp

示例2: length

qreal length( QPair<Node,Node> pair )
{
	QPointF p1 = pair.first.coor();
	QPointF p2 = pair.second.coor();
	QPointF delta = p1 - p2;
	return qSqrt(qPow(delta.x(),2)+qPow(delta.y(),2));

}
开发者ID:duxiaodong,项目名称:graduate-pro,代码行数:8,代码来源:node.cpp

示例3: qSqrt

qreal UltimateTicTacToeMontecarloAI::nodeUCBValue(Node const& node, Nodes const& nodes) const {
  if(node.parent != -1)
  {
    return node.v + c * qSqrt(qLn(nodes.at(node.parent).n) / node.n);
  } else {
    return 0;
  }
}
开发者ID:bzar,项目名称:ultimate-tic-tac-toe,代码行数:8,代码来源:ultimatetictactoemontecarloai.cpp

示例4: setAllowedMove

void controlPoint::setAllowedMove(const QPointF& base, const QPointF& direction) {
	allowedBase = base;
	if (direction == QPointF(0,0)) {
		allowedDirection = direction;
	} else {
		allowedDirection = direction/qSqrt(direction.x()*direction.x()+direction.y()*direction.y());
	}
}
开发者ID:tnachstedt,项目名称:neuronizer,代码行数:8,代码来源:controlPoint.cpp

示例5: transformed

/*!
    \fn QPolygon QMatrix::mapToPolygon(const QRect &rectangle) const

    Creates and returns a QPolygon representation of the given \a
    rectangle, mapped into the coordinate system defined by this
    matrix.

    The rectangle's coordinates are transformed using the following
    formulas:

    \snippet code/src_gui_painting_qmatrix.cpp 3

    Polygons and rectangles behave slightly differently when
    transformed (due to integer rounding), so
    \c{matrix.map(QPolygon(rectangle))} is not always the same as
    \c{matrix.mapToPolygon(rectangle)}.

    \sa mapRect(), {QMatrix#Basic Matrix Operations}{Basic Matrix
    Operations}
*/
QPolygon QMatrix::mapToPolygon(const QRect &rect) const
{
    QPolygon a(4);
    qreal x[4], y[4];
    if (_m12 == 0.0F && _m21 == 0.0F) {
        x[0] = _m11*rect.x() + _dx;
        y[0] = _m22*rect.y() + _dy;
        qreal w = _m11*rect.width();
        qreal h = _m22*rect.height();
        if (w < 0) {
            w = -w;
            x[0] -= w;
        }
        if (h < 0) {
            h = -h;
            y[0] -= h;
        }
        x[1] = x[0]+w;
        x[2] = x[1];
        x[3] = x[0];
        y[1] = y[0];
        y[2] = y[0]+h;
        y[3] = y[2];
    } else {
        qreal right = rect.x() + rect.width();
        qreal bottom = rect.y() + rect.height();
        MAPDOUBLE(rect.x(), rect.y(), x[0], y[0]);
        MAPDOUBLE(right, rect.y(), x[1], y[1]);
        MAPDOUBLE(right, bottom, x[2], y[2]);
        MAPDOUBLE(rect.x(), bottom, x[3], y[3]);
    }
#if 0
    int i;
    for(i = 0; i< 4; i++)
        qDebug("coords(%d) = (%f/%f) (%d/%d)", i, x[i], y[i], qRound(x[i]), qRound(y[i]));
    qDebug("width=%f, height=%f", qSqrt((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0])),
            qSqrt((x[0]-x[3])*(x[0]-x[3]) + (y[0]-y[3])*(y[0]-y[3])));
#endif
    // all coordinates are correctly, tranform to a pointarray
    // (rounding to the next integer)
    a.setPoints(4, qRound(x[0]), qRound(y[0]),
                 qRound(x[1]), qRound(y[1]),
                 qRound(x[2]), qRound(y[2]),
                 qRound(x[3]), qRound(y[3]));
    return a;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:66,代码来源:qmatrix.cpp

示例6: if

void DistortionFXFilter::polarCoordinatesMultithreaded(const Args& prm)
{
    int Width       = prm.orgImage->width();
    int Height      = prm.orgImage->height();
    uchar* data     = prm.orgImage->bits();
    bool sixteenBit = prm.orgImage->sixteenBit();
    int bytesDepth  = prm.orgImage->bytesDepth();
    uchar* pResBits = prm.destImage->bits();

    int nHalfW      = Width / 2;
    int nHalfH      = Height / 2;
    double lfXScale = 1.0;
    double lfYScale = 1.0;
    double lfAngle, lfRadius, lfRadMax;
    double nh, nw, tw;

    if (Width > Height)
    {
        lfYScale = (double)Width / (double)Height;
    }
    else if (Height > Width)
    {
        lfXScale = (double)Height / (double)Width;
    }

    lfRadMax = (double)qMax(Height, Width) / 2.0;

    double th = lfYScale * (double)(prm.h - nHalfH);

    for (int w = prm.start; runningFlag() && (w < prm.stop); ++w)
    {
        tw = lfXScale * (double)(w - nHalfW);

        if (prm.Type)
        {
            // now, we get the distance
            lfRadius = qSqrt(th * th + tw * tw);
            // we find the angle from the center
            lfAngle = qAtan2(tw, th);

            // now we find the exact position's x and y
            nh = lfRadius * (double) Height / lfRadMax;
            nw =  lfAngle * (double)  Width / (2 * M_PI);

            nw = (double)nHalfW + nw;
        }
        else
        {
            lfRadius = (double)(prm.h) * lfRadMax   / (double)Height;
            lfAngle  = (double)(w)     * (2 * M_PI) / (double) Width;

            nw = (double)nHalfW - (lfRadius / lfXScale) * qSin(lfAngle);
            nh = (double)nHalfH - (lfRadius / lfYScale) * qCos(lfAngle);
        }

        setPixelFromOther(Width, Height, sixteenBit, bytesDepth, data, pResBits, w, prm.h, nw, nh, prm.AntiAlias);
    }
}
开发者ID:KDE,项目名称:digikam,代码行数:58,代码来源:distortionfxfilter.cpp

示例7: p

void BenchWidget::paintEvent(QPaintEvent *)
{
    if (m_done)
        return;

    QPainter p(this);

    m_benchmark->begin(&p, 100);

    PaintingRectAdjuster adjuster;
    adjuster.setNewBenchmark(m_benchmark);
    adjuster.reset(rect());

    for (int i = 0; i < 100; ++i)
        m_benchmark->draw(&p, adjuster.newPaintingRect(), i);

    m_benchmark->end(&p);

    ++m_iteration;

    uint currentElapsed = timer.isNull() ? 0 : timer.elapsed();
    timer.restart();

    m_total += currentElapsed;

    // warm up for at most 5 iterations or half a second
    if (m_iteration >= 5 || m_total >= 500) {
        iterationTimes << currentElapsed;

        if (iterationTimes.size() >= 5) {
            qreal mean = 0;
            qreal stddev = 0;
            uint min = INT_MAX;

            for (int i = 0; i < iterationTimes.size(); ++i) {
                mean += iterationTimes.at(i);
                min = qMin(min, iterationTimes.at(i));
            }

            mean /= qreal(iterationTimes.size());

            for (int i = 0; i < iterationTimes.size(); ++i) {
                qreal delta = iterationTimes.at(i) - mean;
                stddev += delta * delta;
            }

            stddev = qSqrt(stddev / iterationTimes.size());

            stddev = 100 * stddev / mean;
            // do 50 iterations, break earlier if we spend more than 5 seconds or have a low std deviation after 2 seconds
            if (iterationTimes.size() >= 50 || m_total >= 5000 || (m_total >= 2000 && stddev < 4)) {
                m_result = min;
                m_done = true;
                return;
            }
        }
    }
}
开发者ID:mpvader,项目名称:qt,代码行数:58,代码来源:tst_qtbench.cpp

示例8: subs_memory

     void Calculator::calculate()
     {

     double operand2     = m_stk.pop().toDouble();
     QString strOperation = m_stk.pop();
     double operand1     = m_stk.pop().toDouble();
     double Result_d     = 0;
     if (strOperation == "+") {
     Result_d  = operand1+operand2;
     }
     if (strOperation == "-")
     {
     Result_d  = operand1-operand2;
     }
     if (strOperation == "/")
     {
     Result_d  = operand1 / operand2;
     }
     if (strOperation == "*")
     {
     Result_d  = operand1 * operand2;
     }
     if (strOperation == "Pow")
     {
       Result_d=qPow(operand1,operand2);
     }
     if (strOperation == "M-")
     {
     subs_memory(operand1);
     }
     if (strOperation == "M+")
     {
     add_memory(operand1);
     }
     if (strOperation == "MS")
     {
     reset_memory();
     }
     if (strOperation == "Sqrt")
     {
     Result_d=qSqrt(operand1);
     }
     if (strOperation == "ln")
     {
     Result_d=qLn(operand1);
     }
     if (strOperation == "MR")
     {
      Result_d=get_memory();

     }
     if (strOperation == "abs")
     {
      Result_d=qAbs(operand1);

     }
     m_plcd->display(Result_d );
     }
开发者ID:DmitriySun,项目名称:Cpp,代码行数:58,代码来源:calculator.cpp

示例9: qSqrt

Number Derivative::smallNumber(Number x)
{
	if (!MathUtils::isNull(x)) {
		return qSqrt(MathUtils::machineEpsilon()) * x;
	}
	else {
		return MathUtils::machineEpsilon();
	}
}
开发者ID:ming13,项目名称:aequatio,代码行数:9,代码来源:derivative.cpp

示例10: fillCircle

void CurveDrawer::fillCircle(const QPointF& center, qreal diameter)
{
	qreal radius = diameter / 2;
	for (int sy = -1; sy <= 1; sy += 2)
	{
		qreal d;
		for (QPoint p(Utils::roundPoint(center)); (d = qSqrt(Utils::normSquared(p - center)) - radius) <= 0; p.ry() += sy)
		{
			for (int sx = -1; sx <= 1; sx += 2)
			{
				for (QPoint pp(p); (d = qSqrt(Utils::normSquared(pp - center)) - radius) <= 0; pp.rx() += sx)
				{
					setPixel(pp, pixelColor(d, 0.));
				}
			}
		}
	}
}
开发者ID:eugenechereshnev,项目名称:computer-graphics,代码行数:18,代码来源:curvedrawer.cpp

示例11: getRange

double getRange(const QPointF &a,const QPointF &b)
{
    double dx = a.x() - b.x();
    double dx2 = dx*dx;
    double dy = a.y() - b.y();
    double dy2 = dy*dy;
    double r = qSqrt(dx2 + dy2);
    return r;
}
开发者ID:Isachenko,项目名称:CG_LABS,代码行数:9,代码来源:canvas.cpp

示例12: qPow

double LevelOneDec::getMu(int i)
{
    double mu = 0;
    for (size_t j = 0; j < col; ++j)
    {
        mu += qPow(vectorSensorReadings2DToLevelOne[i][j], 2);
    }
    return qSqrt(mu);
}
开发者ID:EXL,项目名称:SensorMonitor,代码行数:9,代码来源:LevelOneDecWidget.cpp

示例13: qSqrt

double Nodos::distancia_linea_recta(int inix, int iniy, int metax, int metay)
{

    double adx=abs(metax - inix);
    double ady=abs(metay - iniy);
    double distancia = qSqrt((qPow(adx,2)+(qPow(ady,2))));
    return distancia;
    cout<<"Entro en distancia_linea"<<endl;
}
开发者ID:fernandosanchez1128,项目名称:Proyecto_IA,代码行数:9,代码来源:nodos.cpp

示例14: qSqrt

QPointF CvHelper::norm(double x, double y)
{
	double distance = qSqrt(x * x + y * y);

	if (distance == 0) {
		return QPointF(0, 0);
	}
	return QPointF(x / distance, y / distance);
}
开发者ID:walachey,项目名称:biotracker_core,代码行数:9,代码来源:CvHelper.cpp

示例15: qSqrt

float
CurveGroup::pathLength(Curve *c)
{
  // find total path length  
  int xcount = c->pts.count(); 
  double plen = 0;
  for (int i=1; i<xcount; i++)
    {
      QPoint v = c->pts[i]-c->pts[i-1];
      plen += qSqrt(QPoint::dotProduct(v,v));
    }
  if (c->closed) // for closed curve
    {
      QPoint v = c->pts[0]-c->pts[xcount-1];
      plen += qSqrt(QPoint::dotProduct(v,v));
    }
  return plen;
}
开发者ID:imclab,项目名称:drishti,代码行数:18,代码来源:curvegroup.cpp


注:本文中的qSqrt函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。