0

For a more realistic movement it is necessary to calculate the roll and pitch.

How can I do this by knowing the coordinates of two points?

my code:

void ViewshedGeoElement::animate()
{
    // if (m_missionData == nullptr)
    if (m_missionDataList.isEmpty())
        return;

    int distanceModel = 0;

    for(int u=0;u<m_missionDataList.size();u++)
    {
        qDebug()<<u<<m_missionDataList.size()<<m_missionDataList.at(u)->size()<<QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid);
        // if (missionFrame() < missionSize())
        if (missionFrame() < m_missionDataList.at(u)->size())
        {
            Esri::ArcGISRuntime::LinearUnitId m_linearUnit = Esri::ArcGISRuntime::LinearUnitId::Meters;
            Esri::ArcGISRuntime::AngularUnitId m_angularUnit = Esri::ArcGISRuntime::AngularUnitId::Degrees;
            Esri::ArcGISRuntime::GeodeticCurveType m_curveType = Esri::ArcGISRuntime::GeodeticCurveType::Geodesic;

            // const MissionData::DataPoint& dp = m_missionData->dataAt(missionFrame());
            const MissionData::DataPoint& dp = m_missionDataList.at(u)->dataAt(missionFrame());
            // const MissionData::DataPoint& dp_to = m_missionData->dataAt(missionFrame()+1);

            Point location;

            if (missionFrame()==0)
            {
                location = dp.m_pos;
            } else {
                location = m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->geometry();
            }
            qDebug()<<"location"<<location.x()<<location.y()<<location.z()<<location.m();
            const GeodeticDistanceResult distance = GeometryEngine::distanceGeodetic(location, dp.m_pos,
                                                                                     m_linearUnit, m_angularUnit,
                                                                                     m_curveType);

            // move toward waypoint based on speed and update orientation
            location = GeometryEngine::moveGeodetic(QList<Point>{location}, 1.0, m_linearUnit,
                                                    distance.azimuth1(), m_angularUnit,
                                                    m_curveType).at(0);

            m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->setGeometry(location);

            const double heading = m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->attributes()->attributeValue(m_headingAttr).toDouble();
            const QString newHeading = QString::number(heading + (distance.azimuth1() - heading) / 10);
            qDebug()<<"azimuth2="<<distance.azimuth2()<<"distance="<<distance.distance()<<"newHeading="<<newHeading<<"azimuth1"<<distance.azimuth1()<<"azimuth2"<<distance.azimuth2()<<"dp.m_pitch dp.m_roll"<<dp.m_pitch<<dp.m_roll;
            m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->attributes()->replaceAttribute(m_headingAttr, newHeading);
            // m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->attributes()->replaceAttribute(PITCH, dp.m_pitch);
            // m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->attributes()->replaceAttribute(ROLL, dp.m_roll);
            m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->attributes()->replaceAttribute(PITCH, dp.m_pitch);
            m_ModelControllerGraphic.find(QString::number(m_missionDataList.at(u)->dataAt(missionFrame()).m_uid))->last()->attributes()->replaceAttribute(ROLL, dp.m_roll);
            distanceModel = distance.distance();

        }
    }
    if (distanceModel <= 1)
    {
        playAnimate();
        emit nextFrameRequested();
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.