Example #1
0
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;}

}
Example #2
0
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));

}
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;
  }
}
Example #4
0
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());
	}
}
Example #5
0
/*!
    \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;
}
Example #6
0
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);
    }
}
Example #7
0
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;
            }
        }
    }
}
Example #8
0
     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 );
     }
Example #9
0
void KinematicPoints::SetAB()
{
    double xr = regionalPoint.x();
    double yr = regionalPoint.y();
    double zr = regionalPoint.z();

    a = (-1.0)*l[1] + delta1* qSqrt(qPow(xr, 2) + qPow(yr, 2) - qPow(e, 2));
    b = 0.5/l[2] * (qPow(a, 2) + qPow(zr, 2) + qPow(l[2], 2) - qPow(l[3], 2));
}
Example #10
0
Number Derivative::smallNumber(Number x)
{
	if (!MathUtils::isNull(x)) {
		return qSqrt(MathUtils::machineEpsilon()) * x;
	}
	else {
		return MathUtils::machineEpsilon();
	}
}
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.));
				}
			}
		}
	}
}
Example #12
0
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;
}
Example #13
0
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);
}
Example #14
0
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;
}
Example #15
0
double LevelOneDec::getMuLowerLimit(size_t i)
{
    double mu_lower_limit = 0;
    for (size_t j = 0; j < col; ++j)
    {
        mu_lower_limit += qPow(vector2DSensorReadingsLow[i][j], 2);
    }
    return qSqrt(mu_lower_limit);
}
Example #16
0
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);
}
Example #17
0
double LevelOneDec::getMuHighLimit(size_t i)
{
    double mu_high_limit = 0;
    for (size_t j = 0; j < col; ++j)
    {
        mu_high_limit += qPow(vector2DSensorReadingsHigh[i][j], 2);
    }
    return qSqrt(mu_high_limit);
}
Example #18
0
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;
}
Example #19
0
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));
}
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;
}
Example #21
0
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 &currentSlice = billon.slice(k);
			const Slice &previousSlice = billon.previousSlice(k);
			const iCoord2D &currentPithCoord = 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++;
			}
		}
	}
}
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;
}
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;
}
    virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value){
        if(change == ItemPositionHasChanged){
            QGraphicsEllipseItem *item = qgraphicsitem_cast<QGraphicsEllipseItem *>(parentItem());

            qreal diff = qSqrt(x()*x() + y()*y());
            item->setRect(MakeCircleRect(diff - kCropItemControlPointRadius));
        }

        return QGraphicsEllipseItem::itemChange(change, value);
    }
Example #25
0
void CurveFitter::initBins()
{
    for (int i = 0; i < SPLINE_ORDER; ++i) {
        int a = qMax(i, SPLINE_ORDER - 1 - i);
        bins[i] = 1.0;
        for (int j = a + 1; j <= SPLINE_ORDER - 1; ++j)
            bins[i] *= (qreal) j / (j - a);
    }
    resPhi = 2 - (1 + qSqrt(5)) / 2;
}
bool VerticalPerspectiveProjection::geoCoordinates( const int x, const int y,
                                          const ViewportParams *viewport,
                                          qreal& lon, qreal& lat,
                                          GeoDataCoordinates::Unit unit ) const
{
    Q_D(const VerticalPerspectiveProjection);
    d->calculateConstants(viewport->radius());
    const qreal P = d->m_P;
    const qreal rx = ( - viewport->width()  / 2 + x );
    const qreal ry = (   viewport->height() / 2 - y );
    const qreal p2 = rx*rx + ry*ry;

    if (p2 == 0) {
        lon = viewport->centerLongitude();
        lat = viewport->centerLatitude();
        return true;
    }

    const qreal pP = p2*d->m_pPfactor;

    if ( pP > 1) return false;

    const qreal p = qSqrt(p2);
    const qreal fract = d->m_perspectiveRadius*(P-1)/p;
    const qreal c = qAsin((P-qSqrt(1-pP))/(fract+1/fract));
    const qreal sinc = qSin(c);

    const qreal centerLon = viewport->centerLongitude();
    const qreal centerLat = viewport->centerLatitude();
    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;
}
Example #27
0
Rpn::Operand SquareRoot::calculate(FunctionCalculator *calculator, QList<Rpn::Operand> actualArguments)
{
	Q_UNUSED(calculator);

	Rpn::Operand result;
	result.type = Rpn::OperandNumber;
	result.value = qSqrt(actualArguments.at(0).value.value<Number>());

	return result;
}
Example #28
0
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() );
    }
    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 = 2*ir/qSqrt(2);
        return QColor::fromHsvF( current.hueF(), p.x()/SquareWidth, p.y()/SquareWidth );
    }
    return QColor();
}
QColor ColorWheel::colorPosition(const QPoint &point)
{
    if( ! wheel.rect().contains(point) ) return QColor();
    if(selectedWheel){
        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,
                               start.saturation(),
                               start.value());
    }
    if(selected){
        int w = qMin(width(), height());
        qreal r = w/2-margin;
        qreal ir = r-wWidth;
        qreal m = w/2.0-ir/qSqrt(2);
        QPoint p = point - QPoint(m, m);
        qreal SquareWidth = 2*ir/qSqrt(2);
        return QColor::fromHsvF( start.hueF(),
                                 p.x()/SquareWidth,
                                 p.y()/SquareWidth);
    }
    return QColor();
}
Example #30
0
/*!
 * \brief Reading::errorPropagationPolarToCart
 * Variance propagation to get sigma values for cartesian coordinates
 * \return
 */
OiVec Reading::errorPropagationPolarToCart(){
    OiVec sigmaCartXyz;

    OiMat F(3,3);
    F.setAt(0, 0, qSin(this->rPolar.zenith) * qCos(this->rPolar.azimuth));
    F.setAt(0, 1, this->rPolar.distance * qSin(this->rPolar.zenith) * -qSin(this->rPolar.azimuth));
    F.setAt(0, 2, this->rPolar.distance * qCos(this->rPolar.zenith) * qCos(this->rPolar.azimuth));
    F.setAt(1, 0, qSin(this->rPolar.zenith) * qSin(this->rPolar.azimuth));
    F.setAt(1, 1, this->rPolar.distance * qSin(this->rPolar.zenith) * qCos(this->rPolar.azimuth));
    F.setAt(1, 2, this->rPolar.distance * qCos(this->rPolar.zenith) * qSin(this->rPolar.azimuth));
    F.setAt(2, 0, qCos(this->rPolar.zenith));
    F.setAt(2, 1, 0.0);
    F.setAt(2, 2, this->rPolar.distance * -qSin(this->rPolar.zenith));

    OiMat Sll(3,3);
    Sll.setAt(0, 0, this->rPolar.sigmaDistance * this->rPolar.sigmaDistance);
    Sll.setAt(1, 1, this->rPolar.sigmaAzimuth * this->rPolar.sigmaAzimuth);
    Sll.setAt(2, 2, this->rPolar.sigmaZenith * this->rPolar.sigmaZenith);

    OiMat Qxx = F * Sll * F.t();

    //transform Qxx into homogeneous coordinates
    OiMat Qxx_hc(4,4);
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            Qxx_hc.setAt(i,j, Qxx.getAt(i,j));
        }
    }

    sigmaCartXyz.add(qSqrt(Qxx.getAt(0,0)));
    sigmaCartXyz.add(qSqrt(Qxx.getAt(1,1)));
    sigmaCartXyz.add(qSqrt(Qxx.getAt(2,2)));
    sigmaCartXyz.add(1.0);

    if(this->obs != NULL){
        this->obs->myStatistic.qxx = Qxx_hc;
        this->obs->myStatistic.s0_apriori = 1.0;
        this->obs->myOriginalStatistic = this->obs->myStatistic;
    }

    return sigmaCartXyz;
}