示例#1
0
void WidgetGPS::paintEvent(QPaintEvent *event) {
    myScene->deleteLater();
    myScene = new QGraphicsScene();

    for (int i=0 ; i<coordinatesList.size(); i++) {
        MyPoint point = calculateXY(coordinatesList[i]);
        myScene->addEllipse(point.x,point.y,0.3,0.3,QPen(Qt::transparent),QBrush(Qt::black));
        //qDebug()<<"PX"<<point.x;
        //qDebug()<<"PY"<<point.y;
    }
    MyPoint point = calculateXY(targetCoordinate);
    myScene->addEllipse(point.x,point.y, 0.3, 0.3,QPen(Qt::transparent),QBrush(Qt::red));
    //qDebug()<<"AX"<<point.x;
    //qDebug()<<"AY"<<point.y;

    setScene(myScene);
    QGraphicsView::fitInView(scene()->sceneRect(), Qt::KeepAspectRatio );
    QGraphicsView::paintEvent(event);
}
示例#2
0
文件: allModel.C 项目: pbrach/ball
Eigen::VectorXd ALLModel::predict(const vector<double> & substance, bool transform)
{
    if (descriptor_matrix_.cols() == 0)
    {
        throw Exception::InconsistentUsage(__FILE__, __LINE__, "Training data must be read into the ALL-model before the activity of a substance can be predicted!");
    }
    Eigen::VectorXd v0 = getSubstanceVector(substance, transform);

    Eigen::MatrixXd v(1, v0.rows());
    v.row(0) = v0;
    Eigen::MatrixXd dist;

    // calculate distances between the given substance and the substances of X
    // dimension of dist: 1xn
    calculateEuclDistanceMatrix(v, descriptor_matrix_, dist);
    Eigen::VectorXd w;
    calculateWeights(dist, w);

    Eigen::MatrixXd XX;

    // calculate X.t()*X as cross-products weighted by the similarity of the given substance to the respective row of X
    calculateXX(w, XX);

    Eigen::MatrixXd XY;

    // calculate X.t()*Y_ as cross-products weighted by the similarity of the given substance to the respective row of X
    calculateXY(w, XY);

    // rigde regression in order to be able to cope with linearly dependent columns, i.e. singular matrices
    Eigen::MatrixXd im(XX.rows(), XX.rows());
    im.setIdentity();
    im *= lambda_;
    XX += im;

    Eigen::MatrixXd train = XX.colPivHouseholderQr().solve(XY);

    Eigen::VectorXd res(Y_.cols());
    res = v0.transpose()*train;

    if (transform && y_transformations_.cols() != 0)
    {
        backTransformPrediction(res);
    }

    return res;
}