# Transforms

Core/Transforms.js 23
Contains functions for transforming positions to various reference frames.

### Methods

#### static Cesium.Transforms.computeFixedToIcrfMatrix(date, result) → Matrix3
Core/Transforms.js 629

Computes a rotation matrix to transform a point or vector from the Earth-Fixed frame axes (ITRF) to the International Celestial Reference Frame (GCRF/ICRF) inertial frame axes at a given time. This function may return undefined if the data necessary to do the transformation is not yet loaded.

Name | Type | Description
--- | --- | ---
`date` | JulianDate | The time at which to compute the rotation matrix.
`result` | Matrix3 | optional The object onto which to store the result. If this parameter is not specified, a new instance is created and returned.

##### Returns:

The rotation matrix, or undefined if the data necessary to do the transformation is not yet loaded.

##### Example:

    // Transform a point from the ICRF axes to the Fixed axes.
    var now = Cesium.JulianDate.now();
    var pointInFixed = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var fixedToIcrf = Cesium.Transforms.computeIcrfToFixedMatrix(now);
    var pointInInertial = new Cesium.Cartesian3();
    if (Cesium.defined(fixedToIcrf)) {
        pointInInertial = Cesium.Matrix3.multiplyByVector(fixedToIcrf, pointInFixed, pointInInertial);
    }

##### See:

- Transforms.preloadIcrfFixed

#### static Cesium.Transforms.computeIcrfToFixedMatrix(date, result) → Matrix3
Core/Transforms.js 581

Computes a rotation matrix to transform a point or vector from the International Celestial Reference Frame (GCRF/ICRF) inertial frame axes to the Earth-Fixed frame axes (ITRF) at a given time. This function may return undefined if the data necessary to do the transformation is not yet loaded.

Name | Type | Description
--- | --- | ---
`date` | JulianDate | The time at which to compute the rotation matrix.
`result` | Matrix3 | optional The object onto which to store the result. If this parameter is not specified, a new instance is created and returned.

##### Returns:

The rotation matrix, or undefined if the data necessary to do the transformation is not yet loaded.

##### Example:

    scene.postUpdate.addEventListener(function(scene, time) {
      // View in ICRF.
      var icrfToFixed = Cesium.Transforms.computeIcrfToFixedMatrix(time);
      if (Cesium.defined(icrfToFixed)) {
        var offset = Cesium.Cartesian3.clone(camera.position);
        var transform = Cesium.Matrix4.fromRotationTranslation(icrfToFixed);
        camera.lookAtTransform(transform, offset);
      }
    });

##### See:

- Transforms.preloadIcrfFixed

#### static Cesium.Transforms.computeTemeToPseudoFixedMatrix(date, result) → Matrix3
Core/Transforms.js 448

Computes a rotation matrix to transform a point or vector from True Equator Mean Equinox (TEME) axes to the pseudo-fixed axes at a given time. This method treats the UT1 time standard as equivalent to UTC.

Name | Type | Description
--- | --- | ---
`date` | JulianDate | The time at which to compute the rotation matrix.
`result` | Matrix3 | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix3 instance if none was provided.

##### Example:

    //Set the view to the inertial frame.
    scene.postUpdate.addEventListener(function(scene, time) {
       var now = Cesium.JulianDate.now();
       var offset = Cesium.Matrix4.multiplyByPoint(camera.transform, camera.position, new Cesium.Cartesian3());
       var transform = Cesium.Matrix4.fromRotationTranslation(Cesium.Transforms.computeTemeToPseudoFixedMatrix(now));
       var 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
Core/Transforms.js 219

Computes a 4x4 transformation matrix from a reference frame with an east-north-up axes centered at the provided origin to the provided ellipsoid's fixed reference frame.
通过传入的中心点，生成以这个点为中心的局部坐标系并返回坐标系的四维矩阵。
这个坐标系x轴指向当前点的东方向，y轴指向当前点的北方向，z轴在椭圆体的方向轴指向表面法线穿过的位置。 The local axes are defined as:

- The `x` axis points in the local east direction.
- The `y` axis points in the local north direction.
- The `z` axis points in the direction of the ellipsoid surface normal which passes through the position.

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`result` | Matrix4 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix4 instance if none was provided.

##### Example:

    // Get the transform from local east-north-up at cartographic (0.0, 0.0) to Earth's fixed frame.
    var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var transform = Cesium.Transforms.eastNorthUpToFixedFrame(center);

#### static Cesium.Transforms.fixedFrameToHeadingPitchRoll(transform, ellipsoid, fixedFrameTransform, result) → HeadingPitchRoll
Core/Transforms.js 391

Computes heading-pitch-roll angles from a transform in a particular reference frame. Heading is the rotation from the local north direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.
根据特定参考系的矩阵计算航向、俯仰、滚动角。

Name | Type | Default | Description
--- | --- | --- | ---
`transform` | Matrix4 |  | The transform。需要变换的四维矩阵
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.当前使用的坐标系，可选，默认值：Ellipsoid.WGS84。
`fixedFrameTransform` | Transforms.LocalFrameToFixedFrame | `Transforms.eastNorthUpToFixedFrame` | optional A 4x4 transformation matrix from a reference frame to the provided ellipsoid's fixed reference frame。当前使用全局转局部的方式，也是前面提供的四种，默认Transforms.eastNorthUpToFixedFrame
`result` | HeadingPitchRoll |  | optional The object onto which to store the result.返回值。

##### Returns:

The modified result parameter or a new HeadingPitchRoll instance if none was provided.

#### static Cesium.Transforms.headingPitchRollQuaternion(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result) → Quaternion
Core/Transforms.js 362

Computes a quaternion from a reference frame with axes computed from the heading-pitch-roll angles centered at the provided origin. Heading is the rotation from the local north direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`headingPitchRoll` | HeadingPitchRoll |  | The heading, pitch, and roll.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`fixedFrameTransform` | Transforms.LocalFrameToFixedFrame | `Transforms.eastNorthUpToFixedFrame` | optional A 4x4 transformation matrix from a reference frame to the provided ellipsoid's fixed reference frame
`result` | Quaternion |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Quaternion instance if none was provided.

##### Example:

    // Get the quaternion from local heading-pitch-roll at cartographic (0.0, 0.0) to Earth's fixed frame.
    var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var heading = -Cesium.Math.PI_OVER_TWO;
    var pitch = Cesium.Math.PI_OVER_FOUR;
    var roll = 0.0;
    var hpr = new HeadingPitchRoll(heading, pitch, roll);
    var quaternion = Cesium.Transforms.headingPitchRollQuaternion(center, hpr);

#### static Cesium.Transforms.headingPitchRollToFixedFrame(origin, headingPitchRoll, ellipsoid, fixedFrameTransform, result) → Matrix4
Core/Transforms.js 324

Computes a 4x4 transformation matrix from a reference frame with axes computed from the heading-pitch-roll angles centered at the provided origin to the provided ellipsoid's fixed reference frame. Heading is the rotation from the local north direction where a positive angle is increasing eastward. Pitch is the rotation from the local east-north plane. Positive pitch angles are above the plane. Negative pitch angles are below the plane. Roll is the first rotation applied about the local east axis.
通过HeadingPitchRoll反向计算坐标系的矩阵信息。

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`headingPitchRoll` | HeadingPitchRoll |  | The heading, pitch, and roll.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`fixedFrameTransform` | Transforms.LocalFrameToFixedFrame | `Transforms.eastNorthUpToFixedFrame` | optional A 4x4 transformation matrix from a reference frame to the provided ellipsoid's fixed reference frame
`result` | Matrix4 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix4 instance if none was provided.

##### Example:

    // Get the transform from local heading-pitch-roll at cartographic (0.0, 0.0) to Earth's fixed frame.
    var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var heading = -Cesium.Math.PI_OVER_TWO;
    var pitch = Cesium.Math.PI_OVER_FOUR;
    var roll = 0.0;
    var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
    var transform = Cesium.Transforms.headingPitchRollToFixedFrame(center, hpr);

#### static Cesium.Transforms.localFrameToFixedFrameGenerator(firstAxis, secondAxis) → Transforms.LocalFrameToFixedFrame
Core/Transforms.js 101

Generates a function that computes a 4x4 transformation matrix from a reference frame centered at the provided origin to the provided ellipsoid's fixed reference frame.

Name | Type | Description
--- | --- | ---
`firstAxis` | String | name of the first axis of the local reference frame. Must be 'east', 'north', 'up', 'west', 'south' or 'down'.
`secondAxis` | String | name of the second axis of the local reference frame. Must be 'east', 'north', 'up', 'west', 'south' or 'down'.

##### Returns:

The function that will computes a 4x4 transformation matrix from a reference frame, with first axis and second axis compliant with the parameters,

#### static Cesium.Transforms.northEastDownToFixedFrame(origin, ellipsoid, result) → Matrix4
Core/Transforms.js 244

Computes a 4x4 transformation matrix from a reference frame with an north-east-down axes centered at the provided origin to the provided ellipsoid's fixed reference frame.
通过传入的中心点，生成以这个点为中心的局部坐标系并返回坐标系的四维矩阵。
这个坐标系x轴指向当地的北方，y轴指向当前地点的东方，z轴指向当前地点地表法线穿过的方向，也就是垂直于地表。 The local axes are defined as:

- The `x` axis points in the local north direction.
- The `y` axis points in the local east direction.
- The `z` axis points in the opposite direction of the ellipsoid surface normal which passes through the position.

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`result` | Matrix4 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix4 instance if none was provided.

##### Example:

    // Get the transform from local north-east-down at cartographic (0.0, 0.0) to Earth's fixed frame.
    var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var transform = Cesium.Transforms.northEastDownToFixedFrame(center);

#### static Cesium.Transforms.northUpEastToFixedFrame(origin, ellipsoid, result) → Matrix4
Core/Transforms.js 269

Computes a 4x4 transformation matrix from a reference frame with an north-up-east axes centered at the provided origin to the provided ellipsoid's fixed reference frame.
通过传入的中心点，生成以这个点为中心的局部坐标系并返回坐标系的四维矩阵。
这个坐标系x轴指向北方，y轴垂直于地表，z轴指向于东方。 The local axes are defined as:

- The `x` axis points in the local north direction.
- The `y` axis points in the direction of the ellipsoid surface normal which passes through the position.
- The `z` axis points in the local east direction.

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`result` | Matrix4 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix4 instance if none was provided.

##### Example:

    // Get the transform from local north-up-east at cartographic (0.0, 0.0) to Earth's fixed frame.
    var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var transform = Cesium.Transforms.northUpEastToFixedFrame(center);

#### static Cesium.Transforms.northWestUpToFixedFrame(origin, ellipsoid, result) → Matrix4
Core/Transforms.js 294

Computes a 4x4 transformation matrix from a reference frame with an north-west-up axes centered at the provided origin to the provided ellipsoid's fixed reference frame.
通过传入的中心点，生成以这个点为中心的局部坐标系并返回坐标系的四维矩阵。
这个坐标系x轴指向北方，y轴指向西方，z轴垂直于地表。 The local axes are defined as:

- The `x` axis points in the local north direction.
- The `y` axis points in the local west direction.
- The `z` axis points in the direction of the ellipsoid surface normal which passes through the position.

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`result` | Matrix4 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix4 instance if none was provided.

##### Example:

    // Get the transform from local north-West-Up at cartographic (0.0, 0.0) to Earth's fixed frame.
    var center = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
    var transform = Cesium.Transforms.northWestUpToFixedFrame(center);

#### static Cesium.Transforms.pointToWindowCoordinates(modelViewProjectionMatrix, viewportTransformation, point, result) → Cartesian2
Core/Transforms.js 744

Transform a point from model coordinates to window coordinates.

Name | Type | Description
--- | --- | ---
`modelViewProjectionMatrix` | Matrix4 | The 4x4 model-view-projection matrix.
`viewportTransformation` | Matrix4 | The 4x4 viewport transformation.
`point` | Cartesian3 | The point to transform.
`result` | Cartesian2 | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Cartesian2 instance if none was provided.

#### static Cesium.Transforms.preloadIcrfFixed(timeInterval) → Promise.<void>
Core/Transforms.js 543

Preloads the data necessary to transform between the ICRF and Fixed axes, in either direction, over a given interval. This function returns a promise that, when resolved, indicates that the preload has completed.

Name | Type | Description
--- | --- | ---
`timeInterval` | TimeInterval | The interval to preload.

##### Returns:

A promise that, when resolved, indicates that the preload has completed and evaluation of the transformation between the fixed and ICRF axes will no longer return undefined for a time inside the interval.

##### Example:

    var interval = new Cesium.TimeInterval(...);
    when(Cesium.Transforms.preloadIcrfFixed(interval), function() {
        // the data is now loaded
    });

##### See:

- Transforms.computeIcrfToFixedMatrix
- Transforms.computeFixedToIcrfMatrix
- when

#### static Cesium.Transforms.rotationMatrixFromPositionVelocity(position, velocity, ellipsoid, result) → Matrix3
Core/Transforms.js 793

Transform a position and velocity to a rotation matrix.

Name | Type | Default | Description
--- | --- | --- | ---
`position` | Cartesian3 |  | The position to transform.
`velocity` | Cartesian3 |  | The velocity vector to transform.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`result` | Matrix3 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix3 instance if none was provided.

### Type Definitions

#### Cesium.Transforms.LocalFrameToFixedFrame(origin, ellipsoid, result) → Matrix4
Core/Transforms.js 107

Computes a 4x4 transformation matrix from a reference frame centered at the provided origin to the provided ellipsoid's fixed reference frame.

Name | Type | Default | Description
--- | --- | --- | ---
`origin` | Cartesian3 |  | The center point of the local reference frame.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid whose fixed frame is used in the transformation.
`result` | Matrix4 |  | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Matrix4 instance if none was provided.