Introduction to Math in Cesium

Cesium from entry to project implementation general directory: click

Cesium contains many mathematical calculation methods for processing coordinate conversion, distance calculation, matrix transformation and other operations on the earth's surface. The following is an introduction to some commonly used Cesium mathematics modules and methods:

Cesium.MathModule: This is the most basic mathematics module in Cesium and contains many commonly used mathematical calculation methods, such as:

  • Cesium.Math.toRadians(degrees): Convert angles to radians.
  • Cesium.Math.toDegrees(radians): Convert radians to degrees.
  • Cesium.Math.clamp(value, min, max): Limit a value to a specified range.
  • Cesium.Math.lerp(start, end, t): Computes a value that is interpolated between two values.
  • Cesium.Math.nextPowerOfTwo(n): Calculates the next power of 2 greater than or equal to the given value.
  • Cesium.Math.randomBetween(min, max): Generate a random number within the specified range.

Cesium.EllipsoidModule: This module contains the definition of the Earth ellipsoid and related calculation methods, such as:

  • Cesium.Ellipsoid.WGS84: Represents WGS84 standard ellipsoid.
  • Cesium.Ellipsoid.cartesianToCartographic(cartesian): Convert points in the Cartesian coordinate system to points in the geographic coordinate system.
  • Cesium.Ellipsoid.cartographicToCartesian(cartographic): Convert points in the geographic coordinate system to points in the Cartesian coordinate system.
  • Cesium.Ellipsoid.scaleToGeodeticSurface(cartesian): Project points in the Cartesian coordinate system onto the Earth's surface.
  • Cesium.Ellipsoid.geodeticSurfaceNormal(cartesian): Calculate the normal vector of the Earth's surface at a given point.

Cesium.Cartesian3Module: This module represents a point in the Cartesian coordinate system and contains many point-related calculation methods, such as:

  • Cesium.Cartesian3.fromDegrees(longitude, latitude, height, ellipsoid): Create a point based on latitude, longitude and altitude.
  • Cesium.Cartesian3.distance(point1, point2): Calculate the distance between two points.
  • Cesium.Cartesian3.normalize(vector, result): Normalize the vector to a unit vector.
  • Cesium.Cartesian3.cross(left, right, result): Calculate the cross product of two vectors.
  • Cesium.Cartesian3.dot(left, right): Calculates the dot product of two vectors.

Cesium.Matrix4Module: This module represents a 4x4 matrix and contains many matrix-related calculation methods, such as:

  • Cesium.Matrix4.IDENTITY: Represents a 4x4 identity matrix.
  • Cesium.Matrix4.fromArray(array, startingIndex, result): Create a matrix from an array.
    • array: Array containing matrix elements.
    • startingIndex: The starting index of the matrix element in the array.
    • result: Optional parameter, the matrix object of the output result.
  • Cesium.Matrix4.toArray(matrix, result): Store the elements of the matrix into an array.
    • matrix: The matrix object to be converted.
    • result: Optional parameter, array object of output results.
  • Cesium.Matrix4.multiply(left, right, result): Calculate the product of two matrices.
    • left: The matrix object on the left.
    • right: The matrix object on the right.
    • result: Optional parameter, the matrix object of the output result.
  • Cesium.Matrix4.multiplyTransformation(left, right, result): Calculate the product of two transformation matrices.
    • left: The matrix object on the left.
    • right: The matrix object on the right.
    • result: Optional parameter, the matrix object of the output result.
  • Cesium.Matrix4.multiplyByTranslation(matrix, translation, result): Multiply a matrix by a translation vector.
    • matrix: The matrix object to be multiplied.
    • translation: The translation vector to be added to the matrix.
    • result: Optional parameter, the matrix object of the output result.
  • Cesium.Matrix4.multiplyByUniformScale(matrix, scale, result): Multiply the matrix by a uniform scaling factor.
    • matrix: The matrix object to be multiplied.
    • scale: scaling factor.
    • result: Optional parameter, the matrix object of the output result.
  • Cesium.Matrix4.inverse(matrix, result): Calculates the inverse matrix of a matrix.
    • matrix:Matrix object requiring the inverse matrix.
    • result: Optional parameter, the matrix object of the output result.
  • Cesium.Matrix4.transpose(matrix, result): Calculate the transpose matrix of the matrix.
    • matrix: A matrix object that requires the transposed matrix.
    • result: Optional parameter, the matrix object of the output result.

​:Cesium.Matrix4.extractRotation(matrix, result) Extract the rotation part of the matrix from the matrix.

  • matrix: The matrix object from which the rotation matrix is ​​to be extracted.
  • result: Optional parameter, the matrix object of the output result. If not provided, a new matrix object is created.
  1. Cesium.Matrix4.multiplyByPoint(matrix, cartesian, result): Multiply a point by a matrix.
    • matrix: The matrix object to be multiplied.
    • cartesian: Cartesian coordinate object of the point to be multiplied by the matrix.
    • result: Optional parameter, the Cartesian coordinate object of the output result.
  2. Cesium.Matrix4.multiplyByVector(matrix, vector, result): Multiply a vector by a matrix.
    • matrix: The matrix object to be multiplied.
    • vector: The vector object to be multiplied by the matrix.
    • result: Optional parameter, vector object of the output result.
  3. Cesium.Matrix4.computePerspectiveFieldOfView(fovY, aspectRatio, near, far, result): Calculate the perspective projection matrix.
    • fovY: Field of view angle, expressed in radians.
    • aspectRatio:Viewport aspect ratio.
    • near: Near plane distance.
    • far: Far plane distance.
    • result: Optional parameter, the matrix object of the output result.
  4. Cesium.Matrix4.computeOrthographicOffCenter(left, right, bottom, top, near, far, result): Calculate the orthogonal projection matrix.
    • left: Left plane distance.
    • right: Right plane distance.
    • bottom: Bottom plane distance.
    • top: Top plane distance.
    • near: Near plane distance.
    • far: Far plane distance.
    • result: Optional parameter, the matrix object of the output result.

These methods and properties are part of the Matrix4 module and can help developers calculate and transform matrices.
Welcome to follow my original public account [GISer World]. This sharing ends here.
Insert image description here
Insert image description here

Guess you like

Origin blog.csdn.net/weixin_44857463/article/details/129316350