• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ qAtan2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: qMin

QColor ColorWheel::posColor(const QPoint &point)
{
    if( ! wheel.rect().contains(point) ) return QColor();
    if(inWheel){
        qreal hue = 0;
        int r = qMin(width(), height()) / 2;
        if( point.x() > r ){
            if(point.y() < r ){
                //1
                hue = 90 - (qAtan2( (point.x() - r) , (r - point.y()) )  / 3.14 / 2 * 360);
            }else{
                //4
                hue = 270 + (qAtan2( (point.x() - r) , (point.y() - r ) )  / 3.14 / 2 * 360);
            }
        }else{
            if(point.y() < r ){
                //2
                hue =  90 + (qAtan2( (r - point.x()) , (r - point.y()) )  / 3.14 / 2 * 360);
            }else{
                //3
                hue =  270 - (qAtan2( (r - point.x()) , (point.y() - r ))  / 3.14 / 2 * 360);
            }
        }
        hue = hue>359?359:hue;
        hue = hue<0?0:hue;
        return QColor::fromHsv(hue,
                               current.saturation(),
                               current.value());
    }

    return QColor();
}
开发者ID:nzhome,项目名称:lightcontroller,代码行数:32,代码来源:colorwheel.cpp


示例2: qAtan2

/**
 * @param x x coordinate
 * @param y y coordinate
 */
void CanvasView::moveDrag(int x, int y)
{
	const int dx = _dragx - x;
	const int dy = _dragy - y;

	if(_isdragging==DRAG_ROTATE) {
		qreal preva = qAtan2( width()/2 - _dragx, height()/2 - _dragy );
		qreal a = qAtan2( width()/2 - x, height()/2 - y );
		setRotation(rotation() + qRadiansToDegrees(preva-a));

	} else if(_isdragging==DRAG_ZOOM) {
		if(dy!=0) {
			float delta = qBound(-1.0, dy / 100.0, 1.0);
			if(delta>0) {
				setZoom(_zoom * (1+delta));
			} else if(delta<0) {
				setZoom(_zoom / (1-delta));
			}
		}
	} else if(_isdragging==DRAG_QUICKADJUST1) {
		if(dy!=0) {
			float delta = qBound(-2.0, dy / 10.0, 2.0);
			doQuickAdjust1(delta);
		}
	} else {
		QScrollBar *ver = verticalScrollBar();
		ver->setSliderPosition(ver->sliderPosition()+dy);
		QScrollBar *hor = horizontalScrollBar();
		hor->setSliderPosition(hor->sliderPosition()+dx);
	}

	_dragx = x;
	_dragy = y;
}
开发者ID:horkana,项目名称:Drawpile,代码行数:38,代码来源:canvasview.cpp


示例3: qMin

QColor NQColorWheel::colorFromPosition(const QPoint &point)
{
    if (!pixmapWheel_.rect().contains(point)) return QColor();

    if (insideWheel_) {
        qreal hue = 0;
        int r = qMin(width(), height()) / 2;
        if (point.x() > r) {
            if (point.y() < r) {
                //1
                hue = 90 - (qAtan2((point.x() - r) , (r - point.y()) )  / 3.14 / 2 * 360);
            } else {
                //4
                hue = 270 + (qAtan2( (point.x() - r) , (point.y() - r ) )  / 3.14 / 2 * 360);
            }
        } else {
            if (point.y() < r) {
                //2
                hue =  90 + (qAtan2( (r - point.x()) , (r - point.y()) )  / 3.14 / 2 * 360);
            } else {
                //3
                hue =  270 - (qAtan2( (r - point.x()) , (point.y() - r ))  / 3.14 / 2 * 360);
            }
        }
        hue = hue>359?359:hue;
        hue = hue<0?0:hue;
        return QColor::fromHsv(hue,
                               currentColor_.saturation(),
                               currentColor_.value());
    }

    if (insideSquare_) {
        // region of the widget
        int w = qMin(width(), height());
        // radius of outer circle
        qreal r = w/2-margin_;
        // radius of inner circle
        qreal ir = r-wheelWidth_;
        // left corner of square
        qreal m = w/2.0-ir/qSqrt(2);
        QPoint p = point - QPoint(m, m);
        qreal SquareWidth = 2*ir/qSqrt(2);
        qreal s = p.x()/SquareWidth;
        if (s<0) s = 0.0;
        if (s>1) s = 1.0;
        //if (s<minimumS_) s = minimumS_;
        qreal v = p.y()/SquareWidth;
        if (v<0) v = 0.0;
        if (v>1) v = 1.0;

        return QColor::fromHsvF(currentColor_.hueF(), minimumS_ + s*(1.0-minimumS_), v);
    }

    return QColor();
}
开发者ID:Negusbuk,项目名称:MatDB,代码行数:55,代码来源:nqcolorwheel.cpp


示例4: point

void DrawingPolylineItem::render(QPainter* painter, const DrawingStyleOptions& styleOptions)
{
	DrawingItemPoint* point0 = point(0);
	DrawingItemPoint* point1 = point(numberOfPoints() - 1);
	QList<DrawingItemPoint*> lPoints = points();
	QPolygonF polygon;
	DrawingItemPoint* otherPoint;
	qreal theta;

	// Polyline
	for(auto pointIter = lPoints.begin(); pointIter != lPoints.end(); pointIter++)
		polygon.append((*pointIter)->pos());

	setupPainter(painter, styleOptions, pen());
	painter->drawPolyline(polygon);

	// Arrows
	if (pen().style() != Qt::NoPen)
	{
		QPen arrowPen = pen();
		arrowPen.setStyle(Qt::SolidLine);
		setupPainter(painter, styleOptions, arrowPen, styleOptions.outputBrush(DrawingStyleOptions::Background));

		otherPoint = point(1);
		if (otherPoint)
		{
			theta = qAtan2(otherPoint->y() - point0->y(),
				otherPoint->x() - point0->x()) * 180.0 / 3.1414592654;

			if (Drawing::magnitude(otherPoint->pos() - point0->pos()) > startArrowSize())
				startArrow().render(painter, point0->pos(), theta);
		}

		otherPoint = point(numberOfPoints() - 2);
		if (otherPoint)
		{
			theta = qAtan2(otherPoint->y() - point1->y(),
				otherPoint->x() - point1->x()) * 180.0 / 3.1414592654;

			if (Drawing::magnitude(otherPoint->pos() - point1->pos()) > endArrowSize())
				endArrow().render(painter, point1->pos(), theta);
		}
	}

#ifdef DEBUG_DRAW_ITEM_SHAPE
	painter->setBrush(Qt::magenta);
	painter->setPen(QPen(Qt::magenta, 1));
	painter->drawPath(shape());
#endif
}
开发者ID:jaallen85,项目名称:jade-legacy,代码行数:50,代码来源:DrawingPolyItems.cpp


示例5: qMin

QColor ColorWheel::posColor(const QPoint& point) {
    if (! this->rect().contains(point)) return QColor();

    if (inWheel_) {
        qreal hue = 0;
        int r = qMin(width(), height()) / 2;

        if (point.x() > r) {
            if (point.y() < r) {
                //1
                hue = 90 - (qAtan2((point.x() - r), (r - point.y()))  / 3.14 / 2 * 360);
            } else {
                //4
                hue = 270 + (qAtan2((point.x() - r), (point.y() - r))  / 3.14 / 2 * 360);
            }
        } else {
            if (point.y() < r) {
                //2
                hue =  90 + (qAtan2((r - point.x()), (r - point.y()))  / 3.14 / 2 * 360);
            } else {
                //3
                hue =  270 - (qAtan2((r - point.x()), (point.y() - r))  / 3.14 / 2 * 360);
            }
        }

        int hueI = clamp(static_cast<int>(hue), 0, 359);
        return QColor::fromHsv(hueI,
                               currentColor_.saturation(),
                               currentColor_.value());
    }

    if (inSquare_) {
        // region of the widget
        int w = qMin(width(), height());
        // radius of outer circle
        qreal r = w/2-margin_;
        // radius of inner circle
        qreal ir = r-wheelWidth_;
        // left corner of square
        qreal m = w/2.0 - ir/qSqrt(2);
        QPoint p = point - QPoint(m, m);
        qreal SquareWidth = (ir * qSqrt(2));
        return QColor::fromHsv(currentColor_.hueF(),
                               clamp(static_cast<int>(p.x() / SquareWidth * 255.0), 0, 255),
                               clamp(static_cast<int>(p.y() / SquareWidth * 255.0), 0, 255));
    }
    
    return QColor();
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:49,代码来源:colorwheel.cpp


示例6: qAtan2

double ArcStyle::endValueFromPoint(qreal x, qreal y)
{
    qreal theta = qAtan2(x,-y);
    qreal angle = fmod((theta * M_180_D_PI) + 360,360);
    double v = qFloor(angle) * m_scale;
    return v;
}
开发者ID:the-snowwhite,项目名称:QtQuickVcp,代码行数:7,代码来源:arcstyle.cpp


示例7: cursor_moved

void RLIDisplayWidget::moveCoursor(const QPoint& pos, bool repaint, RadarScale* curscale) {
  QPointF cen = _controlsEngine->getCenterPos();
  float scale = (_rli_scale.len*1852.f) / _maskEngine->getRadius();
  QVector2D cursor_coords = RLIMath::pos_to_coords(QVector2D(12.5000f, -81.6000f), cen, pos, scale);
  emit cursor_moved(cursor_coords);

  const char * dist_fmt = NULL;
  if(repaint)
    _controlsEngine->setCursorPos(pos);

  float peleng = 90.0 * qAtan2(pos.x() - cen.x(), - pos.y() + cen.y()) / acos(0);
  if (peleng < 0)
    peleng = 360 + peleng;

  float distance = sqrt(pow(pos.y() - cen.y(), 2) + pow(pos.x() - cen.x(), 2));

  float ratio = 1;
  if(curscale) {
    const rli_scale_t * scale = curscale->getCurScale();
    if(scale) {
      ratio = scale->len / maskEngine()->getRadius();
      dist_fmt = scale->val_fmt;
    }
  }
  distance *= ratio;

  emit cursor_moved(peleng, distance, dist_fmt);
}
开发者ID:zappa672,项目名称:RLIDisplay,代码行数:28,代码来源:rlidisplaywidget.cpp


示例8: qAtan2

QPainterPath CharLineRecord::painterPath(qreal width_factor)
{
  QPainterPath path;

  qreal radius = width * width_factor / 2.0;
  qreal sx = xs, sy = ys;
  qreal ex = xe, ey = ye;
  qreal dx = ex - sx, dy = ey - sy;

  qreal a = qAtan2(dy, dx);
  qreal rsina = radius * qSin(a), rcosa = radius * qCos(a);

  path.moveTo(sx + rsina, -(sy - rcosa));
  path.lineTo(sx - rsina, -(sy + rcosa));
  path.lineTo(ex - rsina, -(ey + rcosa));
  path.lineTo(ex + rsina, -(ey - rcosa));
  path.closeSubpath();
  if (shape == R) {
    path.addEllipse(QPointF(sx, -sy), radius, radius);
    path.addEllipse(QPointF(ex, -ey), radius, radius);
  } else {
    qreal radius2 = radius * 2;
    path.addRect(sx-radius, -sy-radius, radius2, radius2);
    path.addRect(ex-radius, -ey-radius, radius2, radius2);
  }

  return path;
}
开发者ID:aitjcize,项目名称:QCamber,代码行数:28,代码来源:charrecord.cpp


示例9: while

double OsmAnd::Model::Road::getDirectionDelta( uint32_t originIdx, bool forward, float distance ) const
{
    auto itPoint = (_points.begin() + originIdx);
    const auto itOriginPoint = itPoint;
    float scannedDistance = 0.0;
    do
    {
        if(forward)
        {
            itPoint++;
            if(itPoint == _points.end())
            {
                itPoint--;
                break;
            }
        }
        else
        {
            if(itPoint == _points.begin())
                break;
            itPoint--;
        }

        // translate into meters
        scannedDistance +=
            Utilities::x31toMeters(qAbs((int64_t)itPoint->x - (int64_t)itOriginPoint->x)) +
            Utilities::y31toMeters(qAbs((int64_t)itPoint->y - (int64_t)itOriginPoint->y));
    } while ( scannedDistance < distance );

    return -qAtan2(itOriginPoint->x - itPoint->x, itOriginPoint->y - itPoint->y);
}
开发者ID:cdavila,项目名称:OsmAnd-core,代码行数:31,代码来源:Road.cpp


示例10: width

Qt::ArrowType ArrowDiscWidget::arrowUnderMouse(const QPoint &position) const
{
    const int min_radius_pow2 = 5*5;
    const int max_radius_pow2 = 28*28;

    // mouse coordinates relative to widget topleft
    int mx = position.x();
    int my = position.y();

    // center coordinates relative to widget topleft
    int cx = width()/2;
    int cy = height()/2;

    int px = mx - cx;
    int py = my - cy;

    int const distance_pow2 = px*px + py*py;

    if ( distance_pow2 >= min_radius_pow2 && distance_pow2 <= max_radius_pow2 ) {
        int const angle = int( qAtan2( py, px ) * RAD2DEG );
        Q_ASSERT( -180 <= angle && angle <= 180 );

        if ( angle >= 135 || angle < -135 ) {
            return Qt::LeftArrow;
        } else if ( angle < -45 ) {
            return Qt::UpArrow;
        } else if ( angle < 45 ) {
            return Qt::RightArrow;
        } else {
            return Qt::DownArrow;
        }
    }

    return Qt::NoArrow;
}
开发者ID:KDE,项目名称:marble,代码行数:35,代码来源:ArrowDiscWidget.cpp


示例11: Q_Q

int QDialPrivate::valueFromPoint(const QPoint &p) const
{
    Q_Q(const QDial);
    double yy = (double)q->height()/2.0 - p.y();
    double xx = (double)p.x() - q->width()/2.0;
    double a = (xx || yy) ? qAtan2(yy, xx) : 0;

    if (a < Q_PI / -2)
        a = a + Q_PI * 2;

    int dist = 0;
    int minv = minimum, maxv = maximum;

    if (minimum < 0) {
        dist = -minimum;
        minv = 0;
        maxv = maximum + dist;
    }

    int r = maxv - minv;
    int v;
    if (wrapping)
        v =  (int)(0.5 + minv + r * (Q_PI * 3 / 2 - a) / (2 * Q_PI));
    else
        v =  (int)(0.5 + minv + r* (Q_PI * 4 / 3 - a) / (Q_PI * 10 / 6));

    if (dist > 0)
        v -= dist;

    return !invertedAppearance ? bound(v) : maximum - bound(v);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:31,代码来源:qdial.cpp


示例12: qMax

bool LambertAzimuthalProjection::geoCoordinates( const int x, const int y,
                                          const ViewportParams *viewport,
                                          qreal& lon, qreal& lat,
                                          GeoDataCoordinates::Unit unit ) const
{
    const qint64  radius  = viewport->radius();
    // Calculate how many degrees are being represented per pixel.
    const qreal centerLon = viewport->centerLongitude();
    const qreal centerLat = viewport->centerLatitude();
    const qreal rx = ( - viewport->width()  / 2 + x );
    const qreal ry = (   viewport->height() / 2 - y );
    const qreal p = qMax( qSqrt( rx*rx + ry*ry ), qreal(0.0001) ); // ensure we don't divide by zero
    const qreal c = 2 * qAsin( p / (qSqrt(2) * radius)  );
    const qreal sinc = qSin(c);

    lon = centerLon + qAtan2( rx*sinc , ( p*qCos( centerLat )*qCos( c ) - ry*qSin( centerLat )*sinc  ) );

    while ( lon < -M_PI ) lon += 2 * M_PI;
    while ( lon >  M_PI ) lon -= 2 * M_PI;

    lat = qAsin( qCos(c)*qSin(centerLat) + (ry*sinc*qCos(centerLat))/p );

    if ( unit == GeoDataCoordinates::Degree ) {
        lon *= RAD2DEG;
        lat *= RAD2DEG;
    }

    return true;
}
开发者ID:PayalPradhan,项目名称:marble,代码行数:29,代码来源:LambertAzimuthalProjection.cpp


示例13: ShotEntity

BurstShot::BurstShot(GameState *game, int x, int y, float angle,
                     polarType polarity): ShotEntity(game,x,y,polarity)
{
//    this->game = game;
//    this->x = x;
//    this->y = y;
//    this->polarity = polarity;
    this->angle = angle;
    this->dmg = 10;
    shotSpeed = 750;
    rotatesSpeed = 1080;

    type = BURST;
//    ticker = 0;
//    ticks = 0;
//    lastTick = 0;
//    angle = 90;

    trail.prepend(Point(x,y));
    target.rx() = getX();
    target.ry() = getY()-1000;
    targetAngle = qRadiansToDegrees(qAtan2(target.x()-getX(),target.y()-getY()));
    angleDistance = targetAngle - angle;
    if (angleDistance > 180) {
        angleDistance -= 360;
    } else if (angleDistance < -180) {
        angleDistance += 360;
    }

}
开发者ID:bwarfield,项目名称:WarfieldBrian_CIS17C_48942,代码行数:30,代码来源:burstshot.cpp


示例14: Q_UNUSED

void BurstShot::doLogic(double delta)
{
    Q_UNUSED(delta);
    //set target to point directly above shot
    target.rx() = getX();
    target.ry() = getY()-1000;
    targetDistance = pos.distanceTo(target);
    //target closest enemy if exists
    if(game->getEnemyEntities().size() > 0){
        for(e_ptr enemy: game->getEnemyEntities()){
            if(enemy->getType() == ENEMY){//if the target is not a bullet
                if(pos.distanceTo(enemy->getPos()) < targetDistance){
                    //if distance to enemy is shorter than current target
                    //set it as new target
                    target.rx() = enemy->getX();
                    target.ry() = enemy->getY();
                    targetDistance = pos.distanceTo( target);
                }
            }
        }
    }
    angle = fmod((angle + 360),360.0f);//bind range between 0 and 360
    targetAngle = qRadiansToDegrees(qAtan2(target.x()-getX(),target.y()-getY()));
    angleDistance = targetAngle - angle;
    if (angleDistance > 180) {
        angleDistance -= 360;
    } else if (angleDistance < -180) {
        angleDistance += 360;
    }


}
开发者ID:bwarfield,项目名称:WarfieldBrian_CIS17C_48942,代码行数:32,代码来源:burstshot.cpp


示例15: Q_UNUSED

void Connexion::paint(QPainter *painter,
                      const QStyleOptionGraphicsItem *option,QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    painter->save();

    //MODIFICATION DES COORDONNEES DE DESSINS
    qreal angle = qRadiansToDegrees(qAtan2(n1.y()-n2.y(),n1.x()-n2.x()))+90;
    painter->rotate(angle);
    painter->translate(0, n1.getRadius());

    //DESSIN DE LA CONNEXION
    painter->save();

    QColor c1 = n1.getOwner() != 0 ? n1.getOwner()->getColor() : VACANT_COLOR;
    QColor c2 = n2.getOwner() != 0 ? n2.getOwner()->getColor() : VACANT_COLOR;
    QLinearGradient linearGrad(0, 0, 0, distance);
    linearGrad.setColorAt(0, c1);
    linearGrad.setColorAt(1, c2);
    painter->setPen(Qt::NoPen);
    painter->fillRect(-2, 0, 4, distance, linearGrad);

    painter->restore();

    //DESSIN DES SQUADS

    foreach(Squad *s, lstSquad1To2)
    {
        squadPatern(painter, s);
    }
开发者ID:LukasBitter,项目名称:P2,代码行数:32,代码来源:connexion.cpp


示例16: qAtan2

/*!
  \brief Set the scrolling mode and direction

  Called by QwtAbstractSlider
  \param pos Point in question
  \param scrollMode Scrolling mode
  \param direction Direction
*/
void QwtKnob::getScrollMode( const QPoint &pos, 
    QwtAbstractSlider::ScrollMode &scrollMode, int &direction ) const
{
    const int r = d_data->knobRect.width() / 2;

    const int dx = d_data->knobRect.x() + r - pos.x();
    const int dy = d_data->knobRect.y() + r - pos.y();

    if ( ( dx * dx ) + ( dy * dy ) <= ( r * r ) ) // point is inside the knob
    {
        scrollMode = QwtAbstractSlider::ScrMouse;
        direction = 0;
    }
    else                                // point lies outside
    {
        scrollMode = QwtAbstractSlider::ScrTimer;
        double arc = qAtan2( double( -dx ), double( dy ) ) * 180.0 / M_PI;
        if ( arc < d_data->angle )
            direction = -1;
        else if ( arc > d_data->angle )
            direction = 1;
        else
            direction = 0;
    }
}
开发者ID:TheLortex,项目名称:Robotique-MJC-2011,代码行数:33,代码来源:qwt_knob.cpp


示例17: qSqrt

bool QQuickFrictionAffector::affectParticle(QQuickParticleData *d, qreal dt)
{
    if (!m_factor)
        return false;
    qreal curVX = d->curVX();
    qreal curVY = d->curVY();
    if (!curVX && !curVY)
        return false;
    qreal newVX = curVX + (curVX * m_factor * -1 * dt);
    qreal newVY = curVY + (curVY * m_factor * -1 * dt);

    if (!m_threshold) {
        if (sign(curVX) != sign(newVX))
            newVX = 0;
        if (sign(curVY) != sign(newVY))
            newVY = 0;
    } else {
        qreal curMag = qSqrt(curVX*curVX + curVY*curVY);
        if (curMag <= m_threshold + epsilon)
            return false;
        qreal newMag = qSqrt(newVX*newVX + newVY*newVY);
        if (newMag <= m_threshold + epsilon || //went past the threshold, stop there instead
            sign(curVX) != sign(newVX) || //went so far past maybe it came out the other side!
            sign(curVY) != sign(newVY)) {
            qreal theta = qAtan2(curVY, curVX);
            newVX = m_threshold * qCos(theta);
            newVY = m_threshold * qSin(theta);
        }
    }

    d->setInstantaneousVX(newVX);
    d->setInstantaneousVY(newVY);
    return true;
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:34,代码来源:qquickfriction.cpp


示例18: QColor

QColor ColorWheel::pickColor(const QPoint& point)
{
    if ( ! m_wheelPixmap.rect().contains(point) )
    {
        return QColor();
    }
    if (m_isInWheel)
    {
        qreal hue = 0;
        int r = qMin(width(), height()) / 2;
        QString strDebug = "";
        strDebug += QString("Radius=%1").arg(r);

        QPoint center(width() / 2, height() / 2);

        QPoint diff = point - center;
        strDebug += QString(" Atan2=%1").arg(qAtan2(diff.x(), diff.y()));

        hue = qAtan2( diff.x(), diff.y() ) / M_PI * 180;

        hue = hue + 180; // shift -180~180 to 0~360

        strDebug += QString(" Hue=%1").arg(hue);
        //qDebug() << strDebug;

        hue = (hue > 359) ? 359 : hue;
        hue = (hue < 0) ? 0 : hue;

        return QColor::fromHsv(hue,
            m_currentColor.saturation(),
            m_currentColor.value());
    }
    else if (m_isInSquare)
    {
        QRect rect = m_squareRegion.boundingRect();
        QPoint p = point - rect.topLeft();
        //qDebug("TopRight(%d, %d) Point(%d, %d)", rect.topRight().x(), rect.topRight().y(), point.x(), point.y());
        QSizeF regionSize = rect.size() - QSizeF(1, 1);

        //qDebug("p(%d, %d), Region(%.1f, %.1f)", p.x(), p.y(), regionSize.width(), regionSize.height());
        return QColor::fromHsvF( m_currentColor.hueF(),
            p.x() / regionSize.width(),
            1.0 - (p.y() / regionSize.height()));
    }
    return QColor();
}
开发者ID:CandyFace,项目名称:pencil,代码行数:46,代码来源:colorwheel.cpp


示例19: qAtan2

double CvHelper::orientation(cv::Point2f front, cv::Point2f back)
{
	cv::Point2f diff = front - back;	
	//return qAtan2(diff.x, diff.y);

	// need to check the origin of coorindiates
	return qAtan2(diff.x, diff.y) + CV_PI / 2.0;
}
开发者ID:walachey,项目名称:biotracker_core,代码行数:8,代码来源:CvHelper.cpp


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ qB函数代码示例发布时间:2022-05-30
下一篇:
C++ qAlpha函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap