本文整理汇总了C++中qSqrt函数的典型用法代码示例。如果您正苦于以下问题:C++ qSqrt函数的具体用法?C++ qSqrt怎么用?C++ qSqrt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qSqrt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: pen
TileOutline::TileOutline(Qt::GlobalColor color, QGraphicsItem *parent):QGraphicsPolygonItem(parent)
{
QPen pen(color,2);
setPen(pen);
//set points for hexagon
QVector<QPointF> points;
points << QPointF(-1.0/(qSqrt(3)),-1) << QPointF(1.0/(qSqrt(3)),-1) << QPointF(2.0/(qSqrt(3)),0)
<< QPointF(1.0/(qSqrt(3)),1) << QPointF(-1.0/(qSqrt(3)),1) << QPointF(-2.0/(qSqrt(3)),0);
//scale hexagon
for(size_t i = 0,n = points.size();i<n;i++)
{
points[i]*=HEX_SCALE;
}
setPolygon(QPolygonF(points));
}
开发者ID:Oyinda8,项目名称:Hive-AI,代码行数:18,代码来源:tileoutline.cpp
示例17: qSin
bool LambertAzimuthalProjection::screenCoordinates( const GeoDataCoordinates &coordinates,
const ViewportParams *viewport,
qreal &x, qreal &y, bool &globeHidesPoint ) const
{
const qreal lambda = coordinates.longitude();
const qreal phi = coordinates.latitude();
const qreal lambdaPrime = viewport->centerLongitude();
const qreal phi1 = viewport->centerLatitude();
qreal cosC = qSin( phi1 ) * qSin( phi ) + qCos( phi1 ) * qCos( phi ) * qCos( lambda - lambdaPrime );
// Prevent division by zero
if (cosC <= 0) {
globeHidesPoint = true;
return false;
}
qreal k = qSqrt(2 / (1 + cosC));
// Let (x, y) be the position on the screen of the placemark..
x = ( qCos( phi ) * qSin( lambda - lambdaPrime ) ) * k;
y = ( qCos( phi1 ) * qSin( phi ) - qSin( phi1 ) * qCos( phi ) * qCos( lambda - lambdaPrime ) ) * k;
x *= viewport->radius() / qSqrt(2);
y *= viewport->radius() / qSqrt(2);
const qint64 radius = clippingRadius() * viewport->radius();
if (x*x + y*y > radius * radius) {
globeHidesPoint = true;
return false;
}
globeHidesPoint = false;
x += viewport->width() / 2;
y = viewport->height() / 2 - y;
// Skip placemarks that are outside the screen area
if ( x < 0 || x >= viewport->width() || y < 0 || y >= viewport->height() ) {
return false;
}
return true;
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:44,代码来源:LambertAzimuthalProjection.cpp
示例18: clear
void SectorHistogram::construct( const Billon &billon, const Interval<uint> &sliceInterval, const Interval<int> &intensity,
const uint &zMotionMin, const int &radiusAroundPith )
{
clear();
if ( billon.hasPith() && sliceInterval.isValid() && sliceInterval.width() > 0 )
{
const int &width = billon.n_cols;
const int &height = billon.n_rows;
const qreal squareRadius = qPow(radiusAroundPith,2);
fill(0.,PieChartSingleton::getInstance()->nbSectors());
QVector<int> circleLines;
circleLines.reserve(2*radiusAroundPith+1);
for ( int lineIndex=-radiusAroundPith ; lineIndex<=radiusAroundPith ; ++lineIndex )
{
circleLines.append(qSqrt(squareRadius-qPow(lineIndex,2)));
}
QVector<int>::ConstIterator circlesLinesIterator;
int iRadius;
uint diff;
iCoord2D currentPos;
// Calcul du diagramme en parcourant les tranches du billon comprises dans l'intervalle
for ( uint k=sliceInterval.min() ; k<=sliceInterval.max() ; ++k )
{
const Slice ¤tSlice = billon.slice(k);
const Slice &previousSlice = billon.previousSlice(k);
const iCoord2D ¤tPithCoord = billon.pithCoord(k);
currentPos.y = currentPithCoord.y-radiusAroundPith;
for ( circlesLinesIterator = circleLines.constBegin() ; circlesLinesIterator != circleLines.constEnd() ; ++circlesLinesIterator )
{
iRadius = *circlesLinesIterator;
currentPos.x = currentPithCoord.x-iRadius;
iRadius += currentPithCoord.x;
while ( currentPos.x <= iRadius )
{
if ( currentPos.x < width && currentPos.y < height && intensity.containsOpen(currentSlice.at(currentPos.y,currentPos.x)) &&
intensity.containsOpen(previousSlice.at(currentPos.y,currentPos.x)) )
{
diff = billon.zMotion(currentPos.x,currentPos.y,k);
//if ( motionInterval.containsClosed(diff) )
if ( diff >= zMotionMin )
{
(*this)[PieChartSingleton::getInstance()->sectorIndexOfAngle( currentPithCoord.angle(currentPos) )] += diff-zMotionMin;
}
}
currentPos.x++;
}
currentPos.y++;
}
}
}
}
开发者ID:kerautret,项目名称:TKDetection,代码行数:56,代码来源:sectorhistogram.cpp
示例19: fittedPoints
QPolygonF QwtSplineCurveFitter::fitParametric( const QPolygonF &points ) const
{
int i;
const int size = points.size();
QPolygonF fittedPoints( d_data->splineSize );
QPolygonF splinePointsX( size );
QPolygonF splinePointsY( size );
const QPointF *p = points.data();
QPointF *spX = splinePointsX.data();
QPointF *spY = splinePointsY.data();
double param = 0.0;
for ( i = 0; i < size; i++ )
{
const double x = p[i].x();
const double y = p[i].y();
if ( i > 0 )
{
const double delta = qSqrt( qwtSqr( x - spX[i-1].y() )
+ qwtSqr( y - spY[i-1].y() ) );
param += qMax( delta, 1.0 );
}
spX[i].setX( param );
spX[i].setY( x );
spY[i].setX( param );
spY[i].setY( y );
}
d_data->spline.setPoints( splinePointsX );
if ( !d_data->spline.isValid() )
return points;
const double deltaX =
splinePointsX[size - 1].x() / ( d_data->splineSize - 1 );
for ( i = 0; i < d_data->splineSize; i++ )
{
const double dtmp = i * deltaX;
fittedPoints[i].setX( qRound( d_data->spline.value( dtmp ) ) );
}
d_data->spline.setPoints( splinePointsY );
if ( !d_data->spline.isValid() )
return points;
const double deltaY =
splinePointsY[size - 1].x() / ( d_data->splineSize - 1 );
for ( i = 0; i < d_data->splineSize; i++ )
{
const double dtmp = i * deltaY;
fittedPoints[i].setY( qRound( d_data->spline.value( dtmp ) ) );
}
return fittedPoints;
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:56,代码来源:qwt_curve_fitter.cpp
示例20: equals
void MainWindow:: equals()
{
sNum = value.toDouble();
if (addBool){
total = QString::number(fNum+sNum);
label -> setText(total);
}
if (subtractBool){
total = QString::number(fNum-sNum);
label -> setText(total);
}
if (multiplyBool){
total = QString::number(fNum*sNum);
label -> setText(total);
}
if(divideBool){
total = QString::number(fNum/sNum);
label -> setText(total);
}
if(sinBool){
total = QString::number(qSin(fNum));
label -> setText(total);
}
if(cosBool){
total = QString::number(qCos(fNum));
label -> setText(total);
}
if(tanBool){
total = QString::number(qTan(fNum));
label -> setText(total);
}
if(sqrtBool){
total = QString::number(qSqrt(fNum));
label -> setText(total);
}
if(powBool){
total = QString::number(qPow(fNum,2));
label -> setText(total);
}
if(cubicBool){
total = QString::number(qPow(fNum,3));
label -> setText(total);
}
if(expBool){
total = QString::number(qExp(fNum));
label -> setText(total);
}
if(lnBool){
total = QString::number(qLn(fNum));
label -> setText(total);
}
fNum = 0;
sNum = 0;
}
开发者ID:minusc,项目名称:ScientificCalculator,代码行数:56,代码来源:mainwindow.cpp
注:本文中的qSqrt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论