Transforms

包含用于将位置转换到各种参考系的函数。

Methods

static Cesium.Transforms.computeFixedToIcrfMatrix(date, result)Matrix3|undefined

计算将点或向量从地球固定系轴 (ITRF) 转换到国际天球参考系 (GCRF/ICRF) 惯性系轴的旋转矩阵。 如果尚未加载进行变换所需的数据,此函数可能返回 undefined。
Name Type Description
date JulianDate 计算旋转矩阵的时间。
result Matrix3 optional 用于存储结果的对象。如果未指定此参数,则创建并返回新实例。
Returns:
旋转矩阵,如果执行变换所需的数据尚未加载,则返回 undefined。
Example:
// 将点从固定轴变换到 ICRF 轴。
const now = Cesium.JulianDate.now();
const pointInFixed = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const fixedToIcrf = Cesium.Transforms.computeFixedToIcrfMatrix(now);
let pointInInertial = new Cesium.Cartesian3();
if (Cesium.defined(fixedToIcrf)) {
    pointInInertial = Cesium.Matrix3.multiplyByVector(fixedToIcrf, pointInFixed, pointInInertial);
}
See:

static Cesium.Transforms.computeIcrfToCentralBodyFixedMatrix(date, result)Matrix3|undefined

用于在给定时间计算将点或向量从国际天球参考系 (GCRF/ICRF) 惯性系轴转换到中心天体(通常为地球)固定系轴的旋转矩阵的默认函数, 用于光照和从惯性参考系进行变换。如果尚未加载进行变换所需的数据,此函数可能返回 undefined。
Name Type Description
date JulianDate 计算旋转矩阵的时间。
result Matrix3 optional 用于存储结果的对象。如果未指定此参数,则创建并返回新实例。
Returns:
旋转矩阵,如果执行变换所需的数据尚未加载,则返回 undefined。
Example:
// 将默认的 ICRF 到固定变换设置为月球的变换。
Cesium.Transforms.computeIcrfToCentralBodyFixedMatrix = Cesium.Transforms.computeIcrfToMoonFixedMatrix;
See:

static Cesium.Transforms.computeIcrfToFixedMatrix(date, result)Matrix3|undefined

计算将点或向量从国际天球参考系 (GCRF/ICRF) 惯性系轴转换到地球固定系轴 (ITRF) 的旋转矩阵。 如果尚未加载进行变换所需的数据,此函数可能返回 undefined。
Name Type Description
date JulianDate 计算旋转矩阵的时间。
result Matrix3 optional 用于存储结果的对象。如果未指定此参数,则创建并返回新实例。
Returns:
旋转矩阵,如果执行变换所需的数据尚未加载,则返回 undefined。
Example:
scene.postUpdate.addEventListener(function(scene, time) {
  // 在 ICRF 中查看。
  const icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(time);
  if (Cesium.defined(icrfToFixed)) {
    const offset = Cesium.Cartesian3.clone(camera.position);
    const transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed);
    camera.lookAtTransform(transform, offset);
  }
});
See:

static Cesium.Transforms.computeIcrfToMoonFixedMatrix(date, result)Matrix3

计算将点或向量从国际天球参考系 (GCRF/ICRF) 惯性系轴转换到月球固定系轴的旋转矩阵。
Name Type Description
date JulianDate 计算旋转矩阵的时间。
result Matrix3 optional 用于存储结果的对象。如果未指定此参数,则创建并返回新实例。
Returns:
旋转矩阵。
Example:
// 将默认的 ICRF 到固定变换设置为月球的变换。
Cesium.Transforms.computeIcrfToCentralBodyFixedMatrix = Cesium.Transforms.computeIcrfToMoonFixedMatrix;

static Cesium.Transforms.computeMoonFixedToIcrfMatrix(date, result)Matrix3

计算将点或向量从月球固定系轴转换到国际天球参考系 (GCRF/ICRF) 惯性系轴的旋转矩阵。
Name Type Description
date JulianDate 计算旋转矩阵的时间。
result Matrix3 optional 用于存储结果的对象。如果未指定此参数,则创建并返回新实例。
Returns:
旋转矩阵。
Example:
// 将点从固定轴变换到 ICRF 轴。
const now = Cesium.JulianDate.now();
const pointInFixed = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const fixedToIcrf = Cesium.Transforms.computeMoonFixedToIcrfMatrix(now);
let pointInInertial = new Cesium.Cartesian3();
if (Cesium.defined(fixedToIcrf)) {
    pointInInertial = Cesium.Matrix3.multiplyByVector(fixedToIcrf, pointInFixed, pointInInertial);
}

static Cesium.Transforms.computeTemeToPseudoFixedMatrix(date, result)Matrix3

计算将点或向量从真赤道平春分点 (TEME) 轴转换到给定时间的伪固定轴的旋转矩阵。此方法将 UT1 时间标准视为等效于 UTC。
Name Type Description
date JulianDate 计算旋转矩阵的时间。
result Matrix3 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix3 实例。
Example:
// 将视图设置为惯性系。
scene.postUpdate.addEventListener(function(scene, time) {
   const now = Cesium.JulianDate.now();
   const offset = Cesium.Matrix4.multiplyByPoint(camera.transform, camera.position, new Cesium.Cartesian3());
   const transform = Cesium.Matrix4.fromRotationTranslation(Cesium.Transforms.computeTemeToPseudoFixedMatrix(now));
   const inverseTransform = Cesium.Matrix4.inverseTransformation(transform, new Cesium.Matrix4());
   Cesium.Matrix4.multiplyByPoint(inverseTransform, offset, offset);
   camera.lookAtTransform(transform, offset);
});

static Cesium.Transforms.eastNorthUpToFixedFrame(origin, ellipsoid, result)Matrix4

计算从以提供的原点为中心的东-北-上轴参考系到提供的椭球体固定参考系的 4x4 变换矩阵。 局部轴定义如下:
  • x 轴指向局部东方向。
  • y 轴指向局部北方向。
  • z 轴指向穿过位置的椭球体表面法线方向。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
result Matrix4 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix4 实例。
Example:
// 获取从测绘 (0.0, 0.0) 处的局部东-北-上到地球固定参考系的变换。
const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

static Cesium.Transforms.fixedFrameToHeadingPitchRoll(transform, ellipsoid, fixedFrameTransform, result)HeadingPitchRoll

从特定参考系中的变换计算航向-俯仰-滚转角。航向是从局部东方向的旋转, 正角度向东增加。俯仰是从局部东-北平面的旋转。正俯仰角在平面上方。负俯仰角在平面下方。滚转是围绕局部东轴应用的第一个旋转。
Name Type Default Description
transform Matrix4 变换。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
fixedFrameTransform Transforms.LocalFrameToFixedFrame Transforms.eastNorthUpToFixedFrame optional 从参考系到提供的椭球体固定参考系的 4x4 变换矩阵
result HeadingPitchRoll optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 HeadingPitchRoll 实例。

static Cesium.Transforms.headingPitchRollQuaternion(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result)Quaternion

计算以提供的原点为中心的由航向-俯仰-滚转角计算的轴参考系的四元数。航向是从局部东方向的旋转, 正角度向东增加。俯仰是从局部东-北平面的旋转。正俯仰角在平面上方。负俯仰角在平面下方。滚转是围绕局部东轴应用的第一个旋转。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
headingPitchRoll HeadingPitchRoll 航向、俯仰和滚转。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
fixedFrameTransform Transforms.LocalFrameToFixedFrame Transforms.eastNorthUpToFixedFrame optional 从参考系到提供的椭球体固定参考系的 4x4 变换矩阵
result Quaternion optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Quaternion 实例。
Example:
// 获取从测绘 (0.0, 0.0) 处的局部航向-俯仰-滚转到地球固定参考系的四元数。
const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const heading = -Cesium.Math.PI_OVER_TWO;
const pitch = Cesium.Math.PI_OVER_FOUR;
const roll = 0.0;
const hpr = new HeadingPitchRoll(heading, pitch, roll);
const quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, hpr);

static Cesium.Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result)Matrix4

计算从由航向-俯仰-滚转角计算的轴参考系到提供的椭球体固定参考系的 4x4 变换矩阵, 该参考系以提供的原点为中心。航向是从局部东方向的旋转,正角度向东增加。俯仰是从局部东-北平面的旋转。正俯仰角 在平面上方。负俯仰角在平面下方。滚转是围绕局部东轴应用的第一个旋转。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
headingPitchRoll HeadingPitchRoll 航向、俯仰和滚转。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
fixedFrameTransform Transforms.LocalFrameToFixedFrame Transforms.eastNorthUpToFixedFrame optional 从参考系到提供的椭球体固定参考系的 4x4 变换矩阵
result Matrix4 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix4 实例。
Example:
// 获取从测绘 (0.0, 0.0) 处的局部航向-俯仰-滚转到地球固定参考系的变换。
const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const heading = -Cesium.Math.PI_OVER_TWO;
const pitch = Cesium.Math.PI_OVER_FOUR;
const roll = 0.0;
const hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
const transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, hpr);

static Cesium.Transforms.localFrameToFixedFrameGenerator(firstAxis, secondAxis)Transforms.LocalFrameToFixedFrame

生成一个函数,该函数计算从以提供的原点为中心的参考系到提供的椭球体固定参考系的 4x4 变换矩阵。
Name Type Description
firstAxis string 局部参考系的第一轴名称。必须是 'east'、'north'、'up'、'west'、'south' 或 'down'。
secondAxis string 局部参考系的第二轴名称。必须是 'east'、'north'、'up'、'west'、'south' 或 'down'。
Returns:
将计算从参考系到固定参考系的 4x4 变换矩阵的函数, 第一轴和第二轴与参数一致,

static Cesium.Transforms.northEastDownToFixedFrame(origin, ellipsoid, result)Matrix4

计算从以提供的原点为中心的北-东-下轴参考系到提供的椭球体固定参考系的 4x4 变换矩阵。 局部轴定义如下:
  • x 轴指向局部北方向。
  • y 轴指向局部东方向。
  • z 轴指向与穿过位置的椭球体表面法线相反的方向。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
result Matrix4 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix4 实例。
Example:
// 获取从测绘 (0.0, 0.0) 处的局部北-东-下到地球固定参考系的变换。
const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const transform = Cesium.Transforms.northEastDownToFixedFrame(center);

static Cesium.Transforms.northUpEastToFixedFrame(origin, ellipsoid, result)Matrix4

计算从以提供的原点为中心的北-上-东轴参考系到提供的椭球体固定参考系的 4x4 变换矩阵。 局部轴定义如下:
  • x 轴指向局部北方向。
  • y 轴指向穿过位置的椭球体表面法线方向。
  • z 轴指向局部东方向。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
result Matrix4 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix4 实例。
Example:
// 获取从测绘 (0.0, 0.0) 处的局部北-上-东到地球固定参考系的变换。
const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const transform = Cesium.Transforms.northUpEastToFixedFrame(center);

static Cesium.Transforms.northWestUpToFixedFrame(origin, ellipsoid, result)Matrix4

计算从以提供的原点为中心的北-西-上轴参考系到提供的椭球体固定参考系的 4x4 变换矩阵。 局部轴定义如下:
  • x 轴指向局部北方向。
  • y 轴指向局部西方向。
  • z 轴指向穿过位置的椭球体表面法线方向。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
result Matrix4 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix4 实例。
Example:
// 获取从测绘 (0.0, 0.0) 处的局部北-西-上到地球固定参考系的变换。
const center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const transform = Cesium.Transforms.northWestUpToFixedFrame(center);

static Cesium.Transforms.pointToWindowCoordinates(modelViewProjectionMatrix, viewportTransformation, point, result)Cartesian2

将点从模型坐标变换到窗口坐标。
Name Type Description
modelViewProjectionMatrix Matrix4 4x4 模型-视图-投影矩阵。
viewportTransformation Matrix4 4x4 视口变换。
point Cartesian3 要变换的点。
result Cartesian2 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Cartesian2 实例。

static Cesium.Transforms.preloadIcrfFixed(timeInterval)Promise.<void>

预加载在给定时间区间内在 ICRF 和固定轴之间进行变换所需的数据。此函数返回一个 Promise,当预加载完成时, 该 Promise 将被解析。
Name Type Description
timeInterval TimeInterval 要预加载的时间区间。
Returns:
当预加载完成时解析的 Promise,表明固定轴和 ICRF 轴之间的变换将 不再为区间内的时间返回 undefined。
Example:
const interval = new Cesium.TimeInterval(...);
await Cesium.Transforms.preloadIcrfFixed(interval));
// 数据现已加载
See:

static Cesium.Transforms.rotationMatrixFromPositionVelocity(position, velocity, ellipsoid, result)Matrix3

将位置和速度变换为旋转矩阵。
Name Type Default Description
position Cartesian3 要变换的位置。
velocity Cartesian3 要变换的速度向量。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
result Matrix3 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix3 实例。

Type Definitions

Cesium.Transforms.LocalFrameToFixedFrame(origin, ellipsoid, result)Matrix4

计算从以提供的原点为中心的参考系到提供的椭球体固定参考系的 4x4 变换矩阵。
Name Type Default Description
origin Cartesian3 局部参考系的中心点。
ellipsoid Ellipsoid Ellipsoid.default optional 其固定参考系用于变换的椭球体。
result Matrix4 optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供,则为新的 Matrix4 实例。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.