<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Cesium 路徑運動仿真計算

      需求

      無人機或汽車按照給定的路徑和速度運動

      關(guān)鍵算法

      路徑按比例采樣

      代碼

      simulationPath.js

      /**
       * 仿真路徑
       */
      
      import * as Cesium from 'mars3d-cesium'
      
      let SimulationPath = (function () {
      
          /**
           * 仿真路徑
           * @param { Array<[number, number, number]> } positions 位置集合,位置要首尾相接,即第一個位置和最后一個位置相同
           * @param { number } speed 速度
           * @param { number } unitType 速度單位類型 1:m/s 2:km/h
           */
          function SimulationPath(positions, speed, unitType = 1) {
              this.positions = positions;
              this.speed = speed;
              this.unitType = unitType;
              this.percentage = 0;
              this.lastPos = undefined;
              this.lastTime = undefined;
              this.speedReal = 0;
      
              this.totalDistance = 0;
              this.distances = [];
              this.calculateDistances(this.positions) // 計算距離
          }
      
          SimulationPath.prototype.calculateDistances = function () {
              for (let [i, pos] of this.positions.entries()) {
                  if (i > 0) {
                      let pos1 = this.positions[i - 1];
                      const point1 = Cesium.Cartesian3.fromDegrees(pos1[0], pos1[1], pos1[2]);
                      const point2 = Cesium.Cartesian3.fromDegrees(pos[0], pos[1], pos[2]);
                      const distance = Cesium.Cartesian3.distance(point1, point2);
                      this.distances.push(distance);
                      this.totalDistance += distance;
                  }
              }
          }
      
          /**
           * 路徑按比例采樣
           */
          SimulationPath.prototype.sampleSimulationPath = function () {
              if (this.percentage > 1) this.percentage = 1;
              if (this.percentage < 0) this.percentage = 0;
              let d = this.totalDistance * this.percentage;
              for (let [i, distance] of this.distances.entries()) {
                  d -= distance;
                  if (d <= 0) {
                      d += distance;
                      let pos1 = this.positions[i];
                      let pos2 = this.positions[i + 1];
                      let p = d / distance;
                      let lng = pos1[0] + (pos2[0] - pos1[0]) * p;
                      let lat = pos1[1] + (pos2[1] - pos1[1]) * p;
                      let alt = pos1[2] + (pos2[2] - pos1[2]) * p;
                      return [lng, lat, alt];
                  }
              }
          }
      
          SimulationPath.prototype.updatePosition = function () {
              let deltaTime = 0;
              if (this.lastTime) {
                  deltaTime = new Date().getTime() - this.lastTime;
              }
              if (this.unitType == 1) {
                  this.percentage += deltaTime / 1000.0 / (this.totalDistance / this.speed); // speed單位是m/s
              } else {
                  this.percentage += deltaTime / 1000.0 / 3600.0 / (this.totalDistance / 1000.0 / this.speed); // speed單位是km/h
              }
              if (this.percentage > 1) {
                  this.percentage = 0;
              }
      
              let pos = this.sampleSimulationPath();
      
              if (this.lastPos && this.lastTime) {
                  let distance = Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(this.lastPos[0], this.lastPos[1], this.lastPos[2]), Cesium.Cartesian3.fromDegrees(pos[0], pos[1], pos[2]));
                  if (this.unitType == 1) {
                      this.speedReal = (distance / ((new Date().getTime() - this.lastTime) / 1000.0)); // speed單位是m/s
                  } else {
                      this.speedReal = ((distance / 1000.0) / ((new Date().getTime() - this.lastTime) / 1000.0 / 3600.0)); // speed單位是km/h
                  }
              }
              this.lastPos = pos;
              this.lastTime = new Date().getTime();
      
              return { pos, speedReal: this.speedReal }
          }
      
          return SimulationPath;
      })()
      
      export { SimulationPath }
      

      測試代碼:

      // 無人機仿真飛行路徑
      let path = new SimulationPath(
        [
          [117.1, 31.826, 800],
          [117.088, 31.8261, 756],
          [117.088, 31.825, 723],
          [117.1, 31.8251, 778],
          [117.1, 31.826, 800]
        ],
        20
      )
      
      function renderLoop() {
        requestAnimationFrame(renderLoop)
      
        if (run) {
          let { pos, speedReal } = path.updatePosition()
      
          updateDronePosition(101, 'DV1001', pos[0], pos[1], pos[2], speedReal) // 更新無人機位置
        }
      }
      renderLoop()
      
      posted @ 2025-03-25 14:26  0611163  閱讀(77)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 人成午夜免费视频无码| 日韩欧激情一区二区三区| 中文一区二区视频| 色诱视频在线观看| 国产av亚洲精品ai换脸电影| 人妻中文字幕不卡精品| 熟女亚洲综合精品伊人久久| 熟女少妇精品一区二区| 亚洲男人的天堂一区二区| 国产不卡av一区二区| 亚洲精品熟女国产| 久热这里只有精品12| 小嫩批日出水无码视频免费| 动漫av纯肉无码av在线播放| 国产精品国产片在线观看| 欧美丰满妇大ass| 亚洲男人AV天堂午夜在| 人妻一区二区三区人妻黄色| 日本高清一区免费中文视频| 开鲁县| 亚洲国产精品综合久久网各| 华人在线亚洲欧美精品| 高清中文字幕一区二区| av老司机亚洲精品天堂| 中文日产幕无线码一区中文| 亚洲AV成人片在线观看| 88国产精品视频一区二区三区| 亚洲精品国产一区二区三| 最新国产精品好看的精品| 夜夜爱夜鲁夜鲁很鲁| 日韩av中文字幕有码| 亚洲AV日韩AV综合在线观看| 秋霞AV鲁丝片一区二区| 欧美高清狂热视频60一70| 亚洲天天堂天堂激情性色| 国产 另类 在线 欧美日韩 | 日本丰满老妇bbb| 亚洲第一狼人成人综合网| 人妻少妇偷人精品一区| 欧美肥老太牲交大战| 亚洲乱码日产精品一二三|