Cesium模拟雷达追踪卫星

效果展示

关键代码

//追踪
drawingLeiDa(ldLonLat, wxLonLat, satelliteId, deviceId) {
        let entity = this.viewer.entities.add({
          name: 'leidazhuizong',
          satelliteId: satelliteId,
          deviceId: deviceId,
          ldLonLat: ldLonLat,
          orientation: new Cesium.CallbackProperty(e => {
            let m = getModelMatrix(Cesium.Cartesian3.fromDegrees(ldLonLat.x, ldLonLat.y, ldLonLat.z), Cesium.Cartesian3.fromDegrees(wxLonLat.x, wxLonLat.y, wxLonLat.z));
            let hpr = getHeadingPitchRoll(m);
            hpr.pitch = hpr.pitch + 3.14 / 2 + 3.14;
            return Cesium.Transforms.headingPitchRollQuaternion(Cesium.Cartesian3.fromDegrees(ldLonLat.x, ldLonLat.y, ldLonLat.z), hpr);
          }, false),
          position: new Cesium.CallbackProperty(e => {
            return Cesium.Cartesian3.midpoint(Cesium.Cartesian3.fromDegrees(ldLonLat.x, ldLonLat.y, ldLonLat.z),
              Cesium.Cartesian3.fromDegrees(wxLonLat.x, wxLonLat.y, wxLonLat.z), new Cesium.Cartesian3())
          }, false),
          cylinder: {
            show: false,
            length: new Cesium.CallbackProperty(e => {
              return Cesium.Cartesian3.distance(Cesium.Cartesian3.fromDegrees(ldLonLat.x, ldLonLat.y, ldLonLat.z), Cesium.Cartesian3.fromDegrees(wxLonLat.x, wxLonLat.y, wxLonLat.z))
            }, false),
            topRadius: 100000.0,
            bottomRadius: 100,
            material: Cesium.Color.AQUA.withAlpha(0.9),
          },
        })
        this.leidaArr.push(entity)
      },


//求方位角和朝向
export function getHeadingPitchRoll(m) {
  var m1 = Cesium.Transforms.eastNorthUpToFixedFrame(Cesium.Matrix4.getTranslation(m, new Cesium.Cartesian3()), Cesium.Ellipsoid.WGS84, new Cesium.Matrix4());
  var m3 = Cesium.Matrix4.multiply(Cesium.Matrix4.inverse(m1, new Cesium.Matrix4()), m, new Cesium.Matrix4());
  var mat3 = Cesium.Matrix4.getMatrix3(m3, new Cesium.Matrix3());
  var q = Cesium.Quaternion.fromRotationMatrix(mat3);
  var hpr = Cesium.HeadingPitchRoll.fromQuaternion(q);
  var heading = Cesium.Math.toDegrees(hpr.heading);
  var pitch = Cesium.Math.toDegrees(hpr.pitch);
  var roll = Cesium.Math.toDegrees(hpr.roll);
  return hpr
}

//模型矩阵
export function getModelMatrix(pointA, pointB) {
  const vector2 = Cesium.Cartesian3.subtract(pointB, pointA, new Cesium.Cartesian3());
  //归一化
  const normal = Cesium.Cartesian3.normalize(vector2, new Cesium.Cartesian3());
  const rotationMatrix3 = Cesium.Transforms.rotationMatrixFromPositionVelocity(pointA, normal, Cesium.Ellipsoid.WGS84);
  const orientation = Cesium.Quaternion.fromRotationMatrix(rotationMatrix3);
  const modelMatrix4 = Cesium.Matrix4.fromRotationTranslation(rotationMatrix3, pointA);
  const hpr = Cesium.HeadingPitchRoll.fromQuaternion(orientation);
  return modelMatrix4;
}

根据实际实际可见实际在监听目标移动改变椎体位置

轨道星下点数据通过后端代码计算(不提供)

源码下载:Cesium雷达追踪卫星

QQ:905745690

你可能感兴趣的:(Cesium,vue,java)