Cesium for UE4中的坐标系及其转换

CesiumGeoreference Actor

Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.

Internally, Cesium uses a global Earth-centered,Earth-fixed (ECEF) ellipsoid-centered coordinate system, where the ellipsoid
is usually the World Geodetic System 1984 (WGS84) ellipsoid.

This is a right-handed system centered at the Earth’s center of mass, where +X is in the direction of the intersection of the Equator and the Prime Meridian (zero degrees longitude), +Y is in the direction of the intersection of the Equator and +90 degrees longitude, and +Z is through the North Pole.

This Actor is used by other Cesium Actors to control how this coordinate system is mapped into an Unreal Engine world and level.

CesiumGeoreference的用途主要是控制如何将地理空间坐标转换到虚幻引擎关卡中的坐标。

Cesium 使用的地心空间直角坐标系(ECEF),这里通常使用WGS84椭球体。

地心空间直角坐标系(ECEF)是一个以地球质心为中心的右手系,其中 +X :地球质心指向赤道与本初子午线的交点方向(0经度),+Y:地球质心指向赤道和+90度的子午线的交点方向,+Z:地球质心指向北极方向。

其他 Cesium Actor使用CesiumGeoreference Actor将地心空间直角坐标系(ECEF)映射到虚幻引擎世界和关卡的坐标系当中。

源码分析

涉及到坐标参考系

  1. XYZ: ECEF 地球地心空间直角坐标系。

  2. BLH:地理坐标,经纬度,λ和φ。

  3. ENU: 东北天坐标系,也叫站心坐标系以用户所在位置(Pawn)为坐标原点。坐标系定义为: X轴:指向东边;Y轴:指向北边 ;Z轴:指向天顶。ENU局部坐标系采用三维直角坐标系来描述地球表面,实际应用较为困难,因此一般使用简化后的二维投影坐标系来描述。

  4. UE4的空间直角坐标系,前(x)+右(y)+上(z)。

转换关系如下图所示:

BLH<->ECEF:

地理坐标到地心空间直角坐标的转换(geodetic to geocenter)。

//BLH->ECEF
glm::dvec3cartographicToCartesian(const Cartographic& cartographic) const noexcept;//ECEF->BLHstd::optional<Cartographic>cartesianToCartographic(const glm::dvec3& cartesian) const noexcept;

glm::dvec3 center(0.0, 0.0, 0.0);
const CesiumGeospatial::Ellipsoid& ellipsoid =CesiumGeospatial::Ellipsoid::WGS84;center = ellipsoid.cartographicToCartesian(CesiumGeospatial::Cartographic::fromDegrees(this->OriginLongitude,this->OriginLatitude,this->OriginHeight));

NEU<->ECEF:

两个空间直角坐标系的转换,只要计算出转换矩阵即可。

//ENU 到 ECEF 的转换矩阵
this->_georeferencedToEcef =CesiumGeospatial::Transforms::eastNorthUpToFixedFrame(center);
// 求逆,即ECEF->ENUthis->_ecefToGeoreferenced = glm::affineInverse(this->_georeferencedToEcef);

原点的定义

设置NEU的坐标原点的位置。

UENUM(BlueprintType)
enum class EOriginPlacement : uint8 {/*** Use the tileset's true origin as the Actor's origin. For georeferenced* tilesets, this usually means the Actor's origin will be at the center* of the Earth.*/TrueOrigin UMETA(DisplayName = "True origin"),/** Use the center of the tileset's bounding volume as the Actor's origin. This* option preserves precision by keeping all tileset vertices as close to the* Actor's origin as possible.*/BoundingVolumeOrigin UMETA(DisplayName = "Bounding volume center"),/*** Use a custom position within the tileset as the Actor's origin. The* position is expressed as a longitude, latitude, and height, and that* position within the tileset will be at coordinate (0,0,0) in the Actor's* coordinate system.*/CartographicOrigin UMETA(DisplayName = "Longitude / latitude / height")
};
  1. True origin

    设置NEU和ECEF一致。将Actor的原点设置为地球质心。

  2. Bounding volume center

    使用包围盒的中心作为Actor的原点。这种设置使所有tileset的顶点尽可能的靠近Actor的原点,保证其精度。

  3. Longitude / latitude / height

    使用tileset中自定义的位置来作为Actor的原点。可以使用过经纬度和高程来表示其位置,这样的话在Actor的坐标系统中tileset的位置将会变成(0,0,0)。

四个坐标转换矩阵

  // ENU转ECEF (ENU->XYZ)glm::dmat4 _georeferencedToEcef;// ECEF转ENU (XYZ->ENU)glm::dmat4 _ecefToGeoreferenced;// UE4 绝对坐标转 ECEF glm::dmat4 _ueAbsToEcef;//  ECEF 转 UE4 绝对坐标glm::dmat4 _ecefToUeAbs;

构造函数中四个矩阵初始化为单位矩阵:

ACesiumGeoreference::ACesiumGeoreference(): _georeferencedToEcef(1.0),_ecefToGeoreferenced(1.0),_ueAbsToEcef(1.0),_ecefToUeAbs(1.0),_insideSublevel(false) {PrimaryActorTick.bCanEverTick = true;
}

四个矩阵的更新:

void ACesiumGeoreference::UpdateGeoreference() {// update georeferenced -> ECEF//  将Actor的原点放置在ECEF的中心,即 NEU和ECEF重合。if (this->OriginPlacement == EOriginPlacement::TrueOrigin) {this->_georeferencedToEcef = glm::dmat4(1.0);} else{glm::dvec3 center(0.0, 0.0, 0.0);//将Actor的原点放置在tileset的包围盒中心if (this->OriginPlacement == EOriginPlacement::BoundingVolumeOrigin) {// TODO: it'd be better to compute the union of the bounding volumes and// then use the union's center,//       rather than averaging the centers.// 遍历每一个地理参考的对象,合并计算它们包围盒的中心size_t numberOfPositions = 0;for (const TWeakInterfacePtr<ICesiumGeoreferenceable> pObject : this->_georeferencedObjects) {if(pObject.IsValid() && pObject->IsBoundingVolumeReady()) {std::optional<Cesium3DTiles::BoundingVolume> bv = pObject->GetBoundingVolume();if (bv) {center += Cesium3DTiles::getBoundingVolumeCenter(*bv);++numberOfPositions;}}}if (numberOfPositions > 0) {center /= numberOfPositions;}} //使用自定义经纬度高程设置原点位置else if (this->OriginPlacement == EOriginPlacement::CartographicOrigin) {const CesiumGeospatial::Ellipsoid& ellipsoid = CesiumGeospatial::Ellipsoid::WGS84;//由经纬度高程换算到ECEF中的位置,并将其作为原点center = ellipsoid.cartographicToCartesian(CesiumGeospatial::Cartographic::fromDegrees(this->OriginLongitude,this->OriginLatitude,this->OriginHeight));}// 上述两种center设置是ENU原点在ECEF当中的坐标,ENU->ECEF的计算。this->_georeferencedToEcef =CesiumGeospatial::Transforms::eastNorthUpToFixedFrame(center);}// update ECEF -> georeferenced// 求逆矩阵this->_ecefToGeoreferenced = glm::affineInverse(this->_georeferencedToEcef);// update UE -> ECEF// this->_ueAbsToEcef = this->_georeferencedToEcef *CesiumTransforms::scaleToCesium *CesiumTransforms::unrealToOrFromCesium;// update ECEF -> UEthis->_ecefToUeAbs = CesiumTransforms::unrealToOrFromCesium *CesiumTransforms::scaleToUnrealWorld *this->_ecefToGeoreferenced;//通知所有Object参考系的变化for (TWeakInterfacePtr<ICesiumGeoreferenceable> pObject :this->_georeferencedObjects) {if (pObject.IsValid()) {pObject->NotifyGeoreferenceUpdated();}}this->_setSunSky(this->OriginLongitude, this->OriginLatitude);
}

参考

  1. 地心坐标系
  2. Cesium for UE4 wiki

Cesium for UE4中的坐标系及其转换相关推荐

  1. Cesium球心坐标与本地坐标系经纬转换的数学原理—矩阵变换

    之前整理过:<透析矩阵,由浅入深娓娓道来-高数-线性代数-矩阵>.<三维旋转笔记:欧拉角/四元数/旋转矩阵/轴角-记忆点整理>,这次转载 FuckGIS的<Cesium之 ...

  2. ROS中ENU坐标系与无人机中NED坐标系的转换关系理解

    ROS中ENU坐标系与无人机中NED坐标系的转换关系理解 项目地址 无人机中NED坐标理解 ENU与NED转换 无人机中NED坐标理解 机体坐标系:机体坐标系固连飞机,其原点 取在多旋翼的重心位置上. ...

  3. Cesium中的坐标系及转换

    在我们开始学习Entity之前,我们首先需要先学习下Cesium中的坐标系,Cesium中有多个坐标系,在进行添加Entity时经常会使用到. 一.坐标系介绍 我们先来列举下Cesium中的坐标系:W ...

  4. 双目立体视觉中的坐标系与转换关系 [留意~摄影测量学与计算机视觉学科中的差异]

    文章目录 前言 影像坐标系 相机坐标系 世界坐标系 影像坐标系与相机坐标系之间的相互转换 相机坐标系与世界坐标系之间的相互转换 前言   通过模拟人眼立体视觉,两个摄像机拍摄同一场景可构成双目成像模型 ...

  5. halcon算法库中各坐标系,位姿的解释及原理

    halcon算法库中各坐标系,位姿的解释及原理 前言 在学习halcon和光学原理的过程中,经常会听到像素坐标系,窗口坐标系,世界坐标系等等,很多时候会一头雾水,这时候一定要仔细甄别,了解其原理,才能 ...

  6. GIS中的坐标系定义与转换

    GIS中的坐标系定义与转换 青岛海洋地质研究所 戴勤奋 2002-3-27 14:22:47 ----------------------------------------------------- ...

  7. GIS中的坐标系定义与转换【转】

    1. 椭球体.基准面及地图投影   GIS中的坐标系定义是GIS系统的 基础,正确定义GIS系统的坐标系非常重要.GIS中的坐标系定义由基准面和地图投影两组参数确定,而基准面的定义则由特定椭球体及其对 ...

  8. ArcGIS中的坐标系定义与转换 (转载)

    原文:ArcGIS中的坐标系定义与转换 (转载) 1.基准面概念:  GIS中的坐标系定义由基准面和地图投影两组参数确定,而基准面的定义则由特定椭球体及其对应的转换参数确定,因此欲正确定义GIS系统坐 ...

  9. UE4中的字符串转换

    虚幻4学习---UE4中的字符串转换(文章来自于UE4官方文档) String Conversions: FString To FName FString To Int32 Float To FStr ...

最新文章

  1. mysql have_mysql having用法解析
  2. 快学Scala-第八章 继承
  3. 【看这里】网易云信 IM 红包上线啦!最快3小时集成红包功能
  4. Java开发和运行环境的搭建(详细教程)
  5. Linux shell:执行shell脚本的几种方式
  6. 【mysql】left join on and 和 where的区别
  7. 手把手教你实现机器学习SVM算法
  8. About MS Reporting Service
  9. python基础:列表(list)
  10. 腾讯WebQQ 3.0 密码、验证码加密算法分析
  11. 内忧外患,是否应该为移动设备开发游戏?的?
  12. 江苏大学计算机自动化专业排名2015,自动化专业排名
  13. K8S资源quota配置引起的问题
  14. un-app部署h5项目到普通云服务器--域名解析--OOS对象存储
  15. C++虚函数实现机制
  16. 大数据项目之电商数仓、业务数据介绍、电商系统表结构
  17. 秋招面/笔试题目集合——06
  18. springboot集成mongoDB高级聚合查询,关联查询
  19. 用户名不能包含中文和特殊符号,只能输入英文加数字
  20. 【Linux】fork之后,子进程继承了父进程哪些内容

热门文章

  1. 百度快照劫持技术解析
  2. cross_val_score的用法
  3. linux的top命令cpu,在Linux系统下使用top命令查看CPU使用情况
  4. python导入siri_python-shortcuts:一个利用Python创建Siri快捷方式的库
  5. windows 2003下玩CS“视频无法使用,找不到vids.cvid解压缩程序”的解决办法
  6. 心动测试哪个软件好用,心理测试:4个婚礼现场,哪个最让你心动?测TA会疼爱你多久!...
  7. WPF UIAutomation测试套件开发
  8. html5d调用百度语音,调用百度API,文字转语音
  9. HTML写一首简单的居中唐诗,《唐诗三百首》最简单一首诗,只28字却成压轴之作,誉为诗中绝品...
  10. C语言实现跳动的圣诞树,圣诞节表白去