Advertisement

Cesium航天卫星开发教程之一:基础卫星轨道

阅读量:

教程示例网站:https://thomaz529.github.io

一、效果图

1、轨道类型及特点:

  • 低地球轨道(LEO) :通常位于500-2000公里的高度范围之内,在这一区域执行对地观测、测地、通信以及导航等多种任务。通过Cesium软件模拟LEO卫星运行时长发现,在这一高度范围内运行的卫星具有较快的速度,在视觉呈现上能够较为明显地体现出卫星快速移动的特点。
  • 中地球轨道(MEO) :其运行轨迹位于2000-35786公里的高度区间内,并主要应用于导航系统相关任务。与LEO相比,在Cesium平台中展示出其运动周期较长的特点使得卫星运行速度相对较低。
  • 地球静止轨道(GEO) :该类轨道位于约35786公里的高度位置上并以其特点而闻名——近似静止于赤道平面上方某固定位置这是因为该类卫星的运行周期与地球自转周期完全一致。
  • 太阳同步轨道(SSO) :此类轨高一般低于6000公里并且主要应用于特定区域定时观测任务完成过程中卫星会按照固定的时间间隔经过同一观察点上空。
  • 倾斜地球同步轨道(IGSO) :同样位于约35786公里的高度但与GEO相比具有显著的不同——其运行轨迹所在的平面与赤道平面之间形成了一定的角度这使得在Cesium软件环境中能够直观地观察到卫星沿倾斜路径环绕地球运转的特点并且这种设计能够在特定区域内提供更为良好的覆盖效果。

2、轨道绘制与计算:

  • 基于轨道六根数 :通过轨道半长轴、轨道离心率、轨道倾角、右上升角、近地点角距、平近点角这六个参数来计算卫星位置。先根据公式计算半通径、径向距离、轨道平面上的位置,再计算组合旋转矩阵,最后应用旋转矩阵到轨道平面上的位置向量,得到卫星在空间中的坐标,通过循环修改真近点角可绘制出轨道。
  • 基于 TLE 数据 :利用 TLE 数据中的轨道参数,通过特定算法和公式,如利用卫星运动周期公式等,计算卫星在不同时间点的位置,再将这些位置点连接起来,形成卫星轨道。

3、可视化相关功能:

  • 轨道动态仿真:基于 Cesium 原生交互式播放控制组件和实时时间跟踪组件实现了卫星轨道的动态仿真功能。通过该组件, 用户可以在场景中自由选择启动或暂停动画, 并通过速率调节按钮更改播放速度;实时时间跟踪组件则提供当前模拟时刻信息, 允许用户便捷地切换至任意历史时刻进行观察, 从而全面掌握不同时间段内卫星所在位置及运行轨迹。
  • 卫星与场景交互:(1) 指导用户展示与理解卫星扫描区域;借助 EllipseGraphics 等图形对象来定义卫星扫描范围椭圆。(2) 摄像头位置自动同步于卫星运行状态, 支持两种视角切换: 卫星视点模式以及跟随视点模式, 从而让用户直观感受其运行规律及其轨道特性。

二、代码

为订阅该专栏的粉丝提供依赖库和售后服务!

1、模拟轨道数据

复制代码
 function gerateSatelliteLines(lon, lat) {

    
   const arr = []
    
   for (let i = 0; i <= 360; i += 10) {
    
     arr.push(
    
       lon + i,
    
       lat,
    
       700000
    
     )
    
   }
    
   return arr
    
 }
    
 export default gerateSatelliteLines

2、卫星轨道

复制代码
 import Cesium from '@/cesiumUtils/cesium'

    
  
    
 export default class Roaming {
    
   /** *Creates an instance of satellite roaming.
    
      * @param {*} viewer 需要传入
    
      * @param {*} options.modeluri 模型的uri 需要传入
    
      * @param {*} options.start 开始节点 不需要传入
    
      * @param {*} options.stop  结束节点 不需要传入
    
      * @param {*} options.Lines  点集合 需要传入
    
      * @param {*} options.isPathShow 路径是否显示 默认显示
    
      * @memberof Roaming
    
      */
    
   constructor(viewer, options) {
    
     this.viewer = viewer
    
     this.entity = undefined
    
     this.entity2 = undefined
    
     this.url = options.uri
    
     this.start = undefined
    
     this.stop = undefined
    
     this.Lines = options.Lines
    
     const newLen = options.Lines.length / 3
    
     this.LinesArr = Array(newLen).fill('').map((any, i) => {
    
       return options.Lines.slice(i * 3, (i + 1) * 3)
    
     })
    
     this.isPathShow = options.isPathShow || true
    
     this.InitSatellite(this.computeFlight(this.LinesArr), this.start, this.stop)
    
     this.InitRadarArea(this.computeFlight(this.LinesArr, true), this.start, this.stop, true)
    
   }
    
  
    
   /** * * * @param {*} Lines 点集合
    
      * @param {*} isCone 是否是圆锥区域
    
      * @returns
    
      * @memberof Roaming
    
      */
    
   computeFlight(Lines, isCone) {
    
     const property = new Cesium.SampledPositionProperty()
    
     const start = Cesium.JulianDate.now()
    
     this.start = start
    
     const stop = Cesium.JulianDate.addSeconds(start, 360, new Cesium.JulianDate())
    
     this.stop = stop
    
     this.viewer.clock.startTime = start.clone()
    
     this.viewer.clock.stopTime = stop.clone()
    
     this.viewer.clock.currentTime = start.clone()
    
     // 循环执行
    
     this.viewer.clock.clockRange = Cesium.ClockRange.LOOP_STOP // Loop at the end
    
     // 时间速率,数字越大时间过的越快
    
     // this.viewer.clock.multiplier = 10
    
  
    
     this.viewer.timeline.zoomTo(start, stop)
    
  
    
     Lines.forEach((line, i) => {
    
       const time = Cesium.JulianDate.addSeconds(start, line[0], new Cesium.JulianDate())
    
       const position = Cesium.Cartesian3.fromDegrees(line[0], line[1], isCone ? line[2] / 2 : line[2])
    
       property.addSample(time, position)
    
     })
    
     return property
    
   }
    
  
    
   /** * * 画卫星和卫星的路径
    
      * @param {*} position computeFlight计算的属性
    
      * @param {*} start 开始时间节点
    
      * @param {*} stop 结束时间节点
    
      * @memberof Roaming
    
      */
    
   InitSatellite(position, start, stop) {
    
     this.entity = this.viewer.entities.add({
    
       id: 'satt',
    
       name: '卫星',
    
       label: {
    
     text: '卫星',
    
     backgroundPadding: new Cesium.Cartesian2(7, 7),
    
     showBackground: true,
    
     pixelOffset: new Cesium.Cartesian2(0, -100),
    
     verticalOrigin: Cesium.VerticalOrigin.TOP,
    
     font: '30px sans-serif',
    
     horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
    
     scale: 0.5,
    
     fillColor: Cesium.Color.WHITE,
    
     scaleByDistance: new Cesium.NearFarScalar(10000000, 1, 10000001, 0.0)
    
       },
    
       availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
    
     start,
    
     stop
    
       })]),
    
       // 位置
    
       position,
    
       // 计算朝向
    
       orientation: new Cesium.VelocityOrientationProperty(position),
    
       // 加载模型
    
       model: {
    
     // 模型路径
    
     uri: this.url,
    
     // 模型最小刻度
    
     minimumPixelSize: 20000,
    
     maximumSize: 20000,
    
     // 设置模型最大放大大小
    
     maximumScale: 200000,
    
     // scale: 20000,
    
     runAnimations: true // 是否运行模型中的动画效果
    
       },
    
       path: {
    
     resolution: 1,
    
     material: new Cesium.PolylineGlowMaterialProperty({
    
       glowPower: 0.1,
    
       color: Cesium.Color.WHITE
    
     }),
    
     width: 2
    
       }
    
     })
    
     // 设置连线的曲度
    
     this.entity.position.setInterpolationOptions({
    
       // 曲度
    
       interpolationDegree: 3,
    
       // 点插值 (接近圆)
    
       interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
    
       // 点插值 (直连)
    
       // interpolationAlgorithm: Cesium.LinearApproximation
    
       // // // 点插值 (接近半圆)
    
       // interpolationAlgorithm: Cesium.HermitePolynomialApproximation
    
     })
    
     // 设置相机视角默认在飞机上
    
     // this.viewer.zoomTo(this.entity)
    
     // this.viewer.trackedEntity = this.entity
    
   }
    
  
    
   /** * * 卫星下面的锥形
    
      * @param {*} position computeFlight计算的属性
    
      * @param {*} start 开始时间节点
    
      * @param {*} stop 结束时间节点
    
      * @memberof Roaming
    
      */
    
   InitRadarArea(position, start, stop) {
    
     this.entity2 = this.viewer.entities.add({
    
       availability: new Cesium.TimeIntervalCollection([new Cesium.TimeInterval({
    
     start,
    
     stop
    
       })]),
    
       name: '卫星探测区域',
    
       // 位置
    
       position,
    
       // 计算朝向
    
       orientation: new Cesium.VelocityOrientationProperty(position),
    
       cylinder: {
    
     HeightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
    
     length: 700000,
    
     topRadius: 0,
    
     bottomRadius: 700000,
    
     material: Cesium.Color.BLUE.withAlpha(0.2),
    
     outline: 1,
    
     numberOfVerticalLines: 0,
    
     outlineColor: Cesium.Color.BLUE.withAlpha(0.1)
    
       }
    
     })
    
     // 设置连线的曲度
    
     this.entity2.position.setInterpolationOptions({
    
       // 曲度
    
       interpolationDegree: 5,
    
       // 点插值 (接近圆)
    
       interpolationAlgorithm: Cesium.LagrangePolynomialApproximation
    
     })
    
   }
    
  
    
   /** *漫游的暂停和继续
    
    * * @param {*} state bool类型 false为暂停,ture为继续
    
    * @memberof Roaming
    
    */
    
   PauseOrContinue(state) {
    
     this.viewer.clock.shouldAnimate = state
    
   }
    
  
    
   /** *改变飞行的速度
    
    * * @param {*} value  整数类型
    
    * @memberof Roaming
    
    */
    
   ChangeRoamingSpeed(value) {
    
     this.viewer.clock.multiplier = value
    
   }
    
  
    
   /** * *取消漫游
    
    * @memberof Roaming
    
    */
    
   EndRoaming() {
    
     if (this.entity) {
    
       this.viewer.entities.remove(this.entity)
    
     }
    
     if (this.entity2) {
    
       this.viewer.entities.remove(this.entity2)
    
     }
    
   }
    
 }

全部评论 (0)

还没有任何评论哟~