### Install @math.gl/sun Source: https://github.com/visgl/math.gl/blob/master/docs/modules/sun/README.md Install the library using npm. ```bash npm install @math.gl/sun ``` -------------------------------- ### Install @math.gl/web-mercator Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/README.md Install the library using npm. ```bash npm install @math.gl/web-mercator --save ``` -------------------------------- ### Install @math.gl/dggs-quadkey Source: https://github.com/visgl/math.gl/blob/master/docs/modules/dggs-quadkey/README.md Install the library using npm. This command is used to add the package to your project dependencies. ```bash npm install @math.gl/dggs-quadkey ``` -------------------------------- ### Install @math.gl/types Source: https://github.com/visgl/math.gl/blob/master/docs/modules/types/README.md Install the @math.gl/types package using npm. ```bash npm install @math.gl/types ``` -------------------------------- ### Install Math.gl Core with npm Source: https://github.com/visgl/math.gl/blob/master/docs/developer-guide/get-started.md Use this command to install the core math.gl module if you are using a bundler like webpack. ```bash npm install @math.gl/core ``` -------------------------------- ### Install Polygon Module Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/README.md Install the Polygon module using npm. ```bash npm install @math.gl/polygon ``` -------------------------------- ### Install @math.gl/dggs-s2 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/dggs-s2/README.md Install the library using npm. This command is used to add the package to your project's dependencies. ```bash npm install @math.gl/dggs-s2 ``` -------------------------------- ### Import and Initialize Vector2 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector2.md Import the Vector2 class and create a new instance with initial values. This is the basic setup for using Vector2. ```javascript import {Vector2} from '@math.gl/core'; const vector = new Vector2(1, 1); ``` -------------------------------- ### Cut Polygon by Grid Example Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/cut-polygon-by-grid.md Demonstrates how to use cutPolygonByGrid to subdivide a polygon. Ensure the '@math.gl/polygon' module is imported. ```javascript import {cutPolygonByGrid} from '@math.gl/polygon'; cutPolygonByGrid([0, 15, 15, 0, 0, -15, 0, 15], {size: 2, gridResolution: 20}); // returns [ // [15, 0, 0, -15, 0, 0, 15, 0], // [15, 0, 0, 0, 0, 15, 15, 0] // ] ] ``` -------------------------------- ### Install DGGS Geohash Module Source: https://github.com/visgl/math.gl/blob/master/docs/modules/dggs-geohash/README.md Install the module using npm. ```bash npm install @math.gl/dggs-geohash ``` -------------------------------- ### Cut Polyline by Grid Example Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/cut-polyline-by-grid.md Demonstrates how to use cutPolylineByGrid to subdivide a polyline with a specified grid resolution. Ensure the '@math.gl/polygon' module is imported. ```javascript import {cutPolylineByGrid} from '@math.gl/polygon'; cutPolylineByGrid([-10, -10, 10, 10, 30, -10], {size: 2, gridResolution: 10}); // returns [-10, -10, 0, 0, 10, 10, 20, 0, 30, -10] ``` -------------------------------- ### Initialize and Translate Matrix4 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Copy a matrix to a Matrix4 object for manipulation. This example translates the matrix along the X-axis. ```javascript const IDENTITY = [1, 0, ..., 1]; const m = new Matrix4(IDENTITY).translate([1, 0, 0]); ``` -------------------------------- ### Proj4Projection Usage Source: https://github.com/visgl/math.gl/blob/master/docs/modules/proj4/api-reference/proj4-projection.md Example of how to create a Proj4Projection instance and reproject WGS84 coordinates to another CRS. ```APIDOC ## Usage Reproject WGS84 coordinates to another CRS ```js import {Proj4Projection} from '@math.gl/proj4'; const nad83Proj = '+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees'; const projection = new Proj4Projection({from: 'WGS84', to: nad83Proj}); const wgs84Position = [21, 78, 5000]; const reprojectedPosition = projection.project(wgs84Position); ``` ``` -------------------------------- ### Import Polygon Utility Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon-utils.md Import the getPolygonWindingDirection function from the @math.gl/polygon package. This is a common starting point for using polygon utilities. ```javascript import {getPolygonWindingDirection} from '@math.gl/polygon'; ``` -------------------------------- ### EPSG 4326 Projection Data (JSON) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/proj4/README.md Example JSON response from epsg.io for EPSG:4326, detailing its WKT and Proj4 representations. ```json { "status": "ok", "number_result": 1, "results": [ { "code": "4326", "kind": "CRS-GEOGCRS", "bbox": [90.0, -180.0, -90.0, 180.0], "wkt": "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]", "unit": "degree (supplier to define representation)", "proj4": "+proj=longlat +datum=WGS84 +no_defs", "name": "WGS 84", "area": "World.", "default_trans": 0, "trans": [], "accuracy": "" } ] } ``` -------------------------------- ### Get Quadkey Center Coordinates Source: https://github.com/visgl/math.gl/blob/master/docs/modules/dggs-quadkey/README.md Import and use the getQuadkeyLngLat function to retrieve the longitude and latitude coordinates for the center of a given quadkey. ```javascript import {getQuadkeyLngLat} from '@math.gl/dggs-quadkey'; const center = getQuadkeyLngLat(quadkey); ``` -------------------------------- ### Importing Experimental Features (v2.0) Source: https://github.com/visgl/math.gl/blob/master/docs/upgrade-guide.md Starting from v2.0, experimental exports are prefixed with an underscore (_) and imported directly, rather than being accessed through the `experimental` namespace. ```javascript import {_Euler as Euler} from '@math.gl/core'; ``` ```javascript import {experimental} from '@math.gl/core'; const {Euler} = experimental; ``` -------------------------------- ### Reuse Objects for Performance Source: https://github.com/visgl/math.gl/blob/master/docs/developer-guide/performance.md Avoid object creation overhead by reusing existing objects instead of creating new ones in loops. This example demonstrates replacing object instantiation within a loop with object reuse. ```javascript const tempVector = new Vector3(); for (...) { v.set(x, y, z); } ``` -------------------------------- ### Create and Initialize Vector4 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector4.md Demonstrates how to import and create new Vector4 instances for both vectors and points. ```javascript import {Vector4} from '@math.gl/core'; const vector = new Vector4(1, 1, 1, 0); const point = new Vector4(0, 0, 0, 1); ``` -------------------------------- ### Import and Instantiate Vector3 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector3.md Demonstrates how to import the Vector3 class and create a new Vector3 instance. ```javascript import {Vector3} from '@math.gl/core'; const vector = new Vector3(1, 1, 1); ``` -------------------------------- ### Getting MathArray Length Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/math-array.md Returns the number of elements in the MathArray. ```javascript array.length() ``` -------------------------------- ### getElement() Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix.md Gets the element at a specified conceptual position in the matrix. ```APIDOC ## getElement() ### Description Gets the element at "conceptual position" `M[i][j]`, row major indices by default. ### Method ``` getElement(i: number, j: number, columnMajor: boolean = false): number ``` ### Parameters #### Path Parameters - **i** (number) - Required - The row index. - **j** (number) - Required - The column index. - **columnMajor** (boolean) - Optional - If true, indices are column-major. Defaults to false. ### Returns - **number** - The value of the element at the specified position. ``` -------------------------------- ### Import Core Utilities Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/utilities.md Import necessary functions like 'config' and 'equals' from the @math.gl/core library. ```javascript import {config, equals} from '@math.gl/core'; ``` -------------------------------- ### Get Pose Orientation Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Retrieve the orientation of the pose as an Euler object. ```javascript pose.getOrientation() ``` -------------------------------- ### Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix3.md Creates an empty Matrix3 instance. ```APIDOC ## constructor() Creates an empty `Matrix3` `new Matrix3()` ``` -------------------------------- ### Get Pose Position Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Retrieve the position of the pose as a Vector3 object. ```javascript pose.getPosition() ``` -------------------------------- ### verticalAngle Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector2.md Calculates the clockwise angle in radians starting from the positive y-axis. ```APIDOC ## verticalAngle Calculates clockwise angle in radians starting from positive y axis. ### Signature ```js verticalAngle() ``` Note: returns `Math.atan2(this.x, this.y)` ``` -------------------------------- ### horizontalAngle Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector2.md Calculates the counterclockwise angle in radians starting from the positive x-axis. ```APIDOC ## horizontalAngle Calculates counterclockwise angle in radians starting from positive x axis. ### Signature ```js horizontalAngle() ``` Note: returns `Math.atan2(this.y, this.x)` ``` -------------------------------- ### Configuration Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/utilities.md Allows setting global configuration options for the math.gl library, such as epsilon for comparisons, debug mode, and precision for formatting. ```APIDOC ## configure `configure(options)` ### Description Sets global configuration options for the math.gl library. ### Parameters #### Request Body - **options** (object) - Optional - An object containing configuration properties to set. - **EPSILON** (number) - The epsilon value for numeric comparisons. - **debug** (boolean) - Enables or disables debug mode. - **printRowMajor** (boolean) - Toggles row-major printing format. - **precision** (number) - Sets the default precision for value formatting. ``` -------------------------------- ### Get Quaternion Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/euler.md Returns a Quaternion object representing the rotation defined by the Euler angles. ```javascript euler.getQuaternion() ``` -------------------------------- ### OrientedBoundingBox Constructor and Usage Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/oriented-bounding-box.md Demonstrates how to create an OrientedBoundingBox using its center and half-axes, and how to sort bounding boxes based on their distance to the camera. ```APIDOC ## constructor(center, halfAxes) ### Description Creates an OrientedBoundingBox instance. ### Parameters - `center` (Vector3, optional) - The center of the box. Defaults to `Vector3.ZERO`. - `halfAxes` (Matrix3, optional) - The three orthogonal half-axes of the bounding box, representing rotation and scale. Defaults to `Matrix3.ZERO`. ### Usage Example ```js import {Vector3, Matrix3} from '@math.gl/core'; import {OrientedBoundingBox} from '@math.gl/culling'; const center = new Vector3(1.0, 0.0, 0.0); const halfAxes = new Matrix3().fromScale([1.0, 3.0, 2.0]); const box = new OrientedBoundingBox(center, halfAxes); // Sorting boxes from back to front // Assuming 'boxes' is an array of OrientedBoundingBox instances and 'camera' is defined // boxes.sort( // (boxA, boxB) => // boxB.distanceSquaredTo(camera.positionWC) - boxA.distanceSquaredTo(camera.positionWC) // ); ``` ``` -------------------------------- ### Get Geohash Polygon Source: https://github.com/visgl/math.gl/blob/master/docs/modules/dggs-geohash/README.md Import and use the getGeohashPolygon function to retrieve the polygon for a given geohash. ```javascript import {getGeohashPolygon} from '@math.gl/dggs-geohash'; const polygon = getGeohashPolygon(geohash); ``` -------------------------------- ### WebMercatorViewport Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/api-reference/web-mercator-viewport.md Initializes a new WebMercatorViewport instance with specified map camera states and dimensions. ```APIDOC ## Constructor ### Description Initializes a new WebMercatorViewport instance. ### Parameters - **width** (number) - Optional - Width of viewport. Defaults to 1. - **height** (number) - Optional - Height of viewport. Defaults to 1. - **latitude** (number) - Optional - Latitude of viewport center. Defaults to 0. - **longitude** (number) - Optional - Longitude of viewport center. Defaults to 0. - **zoom** (number) - Optional - Map zoom level. Defaults to 11. - **pitch** (number) - Optional - The pitch (tilt) of the map from the screen, in degrees. Defaults to 0. - **bearing** (number) - Optional - The bearing (rotation) of the map from north, in degrees counter-clockwise. Defaults to 0. - **fovy** (number) - Optional - Field of view of camera in degrees. - **altitude** (number) - Optional - Altitude of camera in screen units. - **position** (number[]) - Optional - Offset of the camera, in meters. Defaults to null. ### Remarks - If either `altitude` or `fovy` is not provided, the missing value is computed from the other. - `width` and `height` are forced to 1 if supplied as 0 to avoid division by zero. - Longitudes and latitudes are specified as degrees. ``` -------------------------------- ### WGS84 Coordinate System Definition (WKT) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/proj4/README.md An example of a WKT CRS definition for WGS84, as found on spatialreference.org. ```text GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] ``` -------------------------------- ### Create and Access Vector2 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/README.md Demonstrates creating a Vector2 instance and accessing its components. Vector2 inherits from Array. ```javascript import {Vector2} from '@math.gl/core'; const vector = new Vector2(1, 2); const x = vector[0]; const y = vector[1]; ``` -------------------------------- ### Get Rotation Matrix (3x3) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Returns a 3x3 rotation matrix representing the rotation component of the current matrix. ```javascript getRotationMatrix3(result?: number[9]) : number[9] ``` -------------------------------- ### Import Pose Class Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Import the Pose class from the @math.gl/core library to use it in your project. ```javascript import {Pose} from '@math.gl/core'; ``` -------------------------------- ### Initialize BoundingSphere with Center and Radius Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/bounding-sphere.md Constructs a new BoundingSphere instance with a specified center and radius. Default values are [0, 0, 0] for center and 0.0 for radius if not provided. ```javascript new BoundingSphere([x, y, z], radius); ``` -------------------------------- ### Get Rotation Matrix (4x4) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Returns a 4x4 rotation matrix representing the rotation component of the current matrix. ```javascript getRotation(result?: number[16]) : number[16] ``` -------------------------------- ### Run math.gl Benchmarks Source: https://github.com/visgl/math.gl/blob/master/docs/developer-guide/performance.md Execute the benchmark suite to evaluate the performance of math.gl operations in your environment. Benchmarks can be run in both Node.js and browser environments. ```bash yarn bench yarn bench browser ``` -------------------------------- ### Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector2.md Creates a new, empty Vector2, or copies an existing Vector2. ```APIDOC ## Constructor Creates a new, empty `Vector2`, or copies an existing `Vector2` ### Signature ```js constructor(x = 0, y = 0) constructor([x, y]) ``` ``` -------------------------------- ### BoundingSphere Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/bounding-sphere.md Initializes a new BoundingSphere with a specified center and radius. ```APIDOC ## constructor(center : Number[3], radius : Number) ### Description Creates a new `BoundingSphere`. ### Parameters - **center** (Number[3]) - Optional, defaults to `[0, 0, 0]`. The center of the bounding sphere. - **radius** (Number) - Optional, defaults to `0.0`. The radius of the bounding sphere. ``` -------------------------------- ### Configure Math.gl Settings Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/utilities.md Set global configuration options for math.gl, such as EPSILON for floating-point comparisons, debug mode, row-major printing, and default precision. ```javascript import {config} from '@math.gl/core'; config.EPSILON = 1e-12; config.debug = true; config.printRowMajor = true; config.precision = 4; ``` -------------------------------- ### Import Quaternion Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/quaternion.md Import the Quaternion class from the @math.gl/core library. This is typically the first step before using any Quaternion functionalities. ```javascript import {Quaternion} from '@math.gl/core'; ``` -------------------------------- ### Get Absolute Area of Polygon Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon.md Calculate the absolute area of the polygon. This is a convenience method that returns the absolute value of the signed area. ```javascript polygon.getArea() ``` -------------------------------- ### Initialize and Use WebMercatorViewport Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/README.md Create a WebMercatorViewport instance for a specific map view and use its project/unproject methods to convert between map and pixel coordinates. Ensure the viewport is configured with appropriate dimensions, location, zoom, pitch, and bearing. ```javascript import WebMercatorViewport from '@math.gl/web-mercator'; // A viewport looking at San Francisco city area const viewport = new WebMercatorViewport({ width: 800, height: 600, longitude: -122.45, latitude: 37.78, zoom: 12, pitch: 60, bearing: 30 }); viewport.project([-122.45, 37.78]); // returns pixel coordinates [400, 300] viewport.unproject([400, 300]); // returns map coordinates [-122.45, 37.78] ``` -------------------------------- ### Get Sun Direction in JavaScript Source: https://github.com/visgl/math.gl/blob/master/docs/modules/sun/README.md Import and use the getSunDirection function with a timestamp, latitude, and longitude to calculate the sun's direction. ```javascript import {getSunDirection} from '@math.gl/sun'; const latitude = 37.7749; const longitude = -122.4194; const sunDir = getSunDirection(Date.now(), latitude, longitude); ``` -------------------------------- ### constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/proj4/api-reference/proj4-projection.md Creates a new Proj4Projection instance for converting between specified coordinate systems. ```APIDOC ## Methods ### `constructor(options: {from?: string, to?: string})` Create a new `Proj4Projection` instance that can convert between the specified coordinate systems. ``` -------------------------------- ### Getting Squared Length of MathArray Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/math-array.md Calculates and returns the squared length (magnitude) of the MathArray. This is computationally cheaper than calculating the actual length. ```javascript array.lengthSquared() ``` -------------------------------- ### Import Matrix3 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix3.md Import the Matrix3 class from the math.gl library. ```javascript import {Matrix3} from `math.gl`; ``` -------------------------------- ### Get Winding Direction of Polygon Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon.md Determine the winding direction of the polygon path. Returns a positive number for clockwise and a negative number for counter-clockwise. ```javascript polygon.getWindingDirection() ``` -------------------------------- ### Simple Vector3 Rotations Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector3.md Illustrates how to rotate a Vector3 around the origin or a specified point using rotateX. ```javascript const v = new Vector3([1, 0, 0]); v.rotateX({radians: Math.PI / 4}); // Rotate around the origin v.rotateX({radians: Math.PI / 4, origin: [1, 1, 0]}); // Rotate around the specified point ``` -------------------------------- ### fromValues Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/quaternion.md Initializes a quaternion with the provided x, y, z, and w values. ```APIDOC ## fromValues `fromValues(x: number, y: number, z: number, w): number: this` Creates a new quat initialized with the given values. ``` -------------------------------- ### Get Signed Area of Polygon Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon.md Calculate the signed area of the polygon. The sign indicates the winding direction: positive for clockwise, negative for counter-clockwise. ```javascript polygon.getSignedArea() ``` -------------------------------- ### Get Axis and Angle Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/quaternion.md Retrieves the rotation axis and angle from a quaternion. It may return functionally equivalent values, favoring positive angles. ```javascript quaternion.getAxisAngle() ``` -------------------------------- ### fitBounds(bounds, options) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/api-reference/web-mercator-viewport.md Calculates and returns a new `WebMercatorViewport` instance that fits the given bounding box. Supports padding, offset, minimum extent, and maximum zoom level. ```APIDOC ## fitBounds(bounds, options) ### Description Get a new flat viewport that fits around the given bounding box. ### Parameters #### Path Parameters - `bounds` ([[number,number],[number,number]]) - Required - an array of two opposite corners of the bounding box. Each corner is specified in `[lon, lat]`. #### Query Parameters - `options` (object) - Optional - `options.padding` (number|{top:number, bottom: number, left: number, right: number}) - Optional - The amount of padding in pixels to add to the given bounds from the edge of the viewport. If padding is set as object, all parameters are required. - `options.offset` ([number,number]) - Optional - The center of the given bounds relative to the viewport's center, `[x, y]` measured in pixels. - `opts.minExtent` (number) - Optional - If supplied, the bounds used to calculate the new map settings will be expanded if the delta width or height of the supplied `bounds` is smaller than this value. - `opts.maxZoom` (number) - Optional - Default: `24` - The returned zoom value will be capped to this value. Avoids returning infinite `zoom` when the supplied `bounds` have zero width or height deltas. ### Returns - A new `WebMercatorViewport` instance ``` -------------------------------- ### Get Rotation Matrix Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/euler.md Returns a Matrix4 object representing the rotation defined by the Euler angles. An optional Matrix4 can be provided to store the result. ```javascript euler.getRotationMatrix(m = new Matrix4()) ``` -------------------------------- ### Create a Plane from coefficients Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/plane.md Initialize a Plane using the coefficients of its general equation `ax + by + cz + d = 0`. The input coefficients must be normalized. ```javascript Plane.fromCoefficients(coefficients : Number[4]) : Plane ``` -------------------------------- ### Create Quaternion from Values Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/quaternion.md Initializes a new quaternion with the specified x, y, z, and w values. ```javascript fromValues(x, y, z, w) ``` -------------------------------- ### Create OrientedBoundingBox Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/oriented-bounding-box.md Instantiate an OrientedBoundingBox using its center and half-axes. Ensure necessary imports for Vector3, Matrix3, and OrientedBoundingBox. ```javascript import {Vector3} from '@math.gl/core'; import {OrientedBoundingBox} from '@math.gl/culling'; const center = new Vector3(1.0, 0.0, 0.0); const halfAxes = new Matrix3().fromScale([1.0, 3.0, 2.0]); const box = new OrientedBoundingBox(center, halfAxes); ``` -------------------------------- ### getBoundingRegion(options) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/api-reference/web-mercator-viewport.md Gets the vertices that define the current visible region of the map. Similar to `getBounds`, it accepts an optional `z` parameter for elevation-specific calculations. ```APIDOC ## getBoundingRegion(options) ### Description Get the vertices of the current visible region. ### Parameters #### Query Parameters - `options` (Object) - Optional - `options.z` (number) - Optional - To calculate a bounding volume for fetching 3D data, this option can be used to get the bounding region at a specific elevation. Default `0`. ### Returns - An array of 4 corners in `[longitude, latitude, altitude]` that define the visible region. ``` -------------------------------- ### Import Matrix4 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Import the Matrix4 class from the math.gl library. ```javascript import {Matrix4} from `math.gl`; ``` -------------------------------- ### Get Scale Vector Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Returns the 3-element scale vector component of the affine transform described by the matrix. An optional result vector can be provided for performance. ```javascript getScale(result?: number[3]) : number[3] ``` -------------------------------- ### Get Translation Vector Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Returns the 3-element translation vector component of the affine transform described by the matrix. An optional result vector can be provided for performance. ```javascript getTranslation(result?: number[3]) : number[3] ``` -------------------------------- ### Vector2 Constructor Overloads Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector2.md Demonstrates the two ways to construct a Vector2: by providing individual x and y components, or by passing an array containing the x and y components. ```javascript constructor((x = 0), (y = 0)); ``` ```javascript constructor([x, y]); ``` -------------------------------- ### Get Polygon Winding Direction (Array of Points) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon-utils.md Determines the winding direction of a polygon represented as an array of points. Returns a positive number for clockwise and a negative number for counter-clockwise. ```javascript getPolygonWindingDirectionPoints(points, options) ``` -------------------------------- ### Import Euler Class Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/euler.md Import the Euler class from the @math.gl/core library. ```javascript import {Euler} from '@math.gl/core'; ``` -------------------------------- ### Get Polygon Signed Area (Array of Points) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon-utils.md Calculates the signed area of a polygon represented as an array of points. Use this when your polygon data is structured as an array of point objects or arrays. ```javascript getPolygonSignedAreaPoints(points, options) ``` -------------------------------- ### Create AxisAlignedBoundingBox from two corners Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/axis-aligned-bounding-box.md Instantiate an AxisAlignedBoundingBox using its minimum and maximum corner coordinates. Ensure the imported class is correctly referenced. ```javascript import {AxisAlignedBoundingBox} from '@math.gl/culling'; const box = new AxisAlignedBoundingBox([-1, -1, -1], [1, 1, 1]); ``` -------------------------------- ### Get Polygon Winding Direction (Flat Array) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon-utils.md Determines the winding direction of a polygon represented as a flat array of points. Returns a positive number for clockwise and a negative number for counter-clockwise. ```javascript getPolygonWindingDirection(points, options) ``` -------------------------------- ### Create OrientedBoundingBox from Half-Size and Quaternion Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/oriented-bounding-box.md Construct an OrientedBoundingBox using its center, half-size dimensions, and orientation represented by a quaternion. ```javascript fromCenterHalfSizeQuaternion(center : number[], halfSize : number[], quaternion : number[]) : OrientedBoundingBox ``` -------------------------------- ### Get Polygon Signed Area (Flat Array) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/polygon-utils.md Calculates the signed area of a polygon represented as a flat array of points. The 'plane' option determines the projection plane for 3D polygons. ```javascript getPolygonSignedArea(points, options, plane) ``` -------------------------------- ### Get East-North-Up to Fixed Frame Transform Source: https://github.com/visgl/math.gl/blob/master/docs/modules/geospatial/README.md Retrieves the transform matrix from a local east-north-up frame to Earth's fixed frame at a specified cartographic position. Requires importing `Ellipsoid` from `@math.gl/geospatial`. ```javascript import {Ellipsoid} from '@math.gl/geospatial'; const transformMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame([0, 0, 0]); ``` -------------------------------- ### Matrix4 Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Creates an empty Matrix4. Arguments can be plain JavaScript arrays or other math.gl objects. ```APIDOC ## new Matrix4() ### Description Creates an empty `Matrix4`. ### Method `new Matrix4()` ``` -------------------------------- ### Pose Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Initialize a new Pose object using either individual position and rotation components or combined position and orientation objects. Rotation components (roll, pitch, yaw) should be in radians. ```javascript new Pose({x, y, z, roll, pitch, yaw}); ``` ```javascript new Pose({position, orientation}); ``` -------------------------------- ### Get Transformation Matrix To Another Pose Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Calculate a 4x4 matrix to transform coordinates from the current pose's coordinate system into the coordinate system of a second pose (otherPose). This is the inverse operation of getTransformationMatrixFromPose. ```javascript pose.getTransformationMatrixToPose(otherPose) ``` -------------------------------- ### Triangulate Polygon with Hole - @math.gl/polygon Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/earcut.md Triangulate a polygon that contains holes by providing an array of hole indices. The hole indices specify the starting vertex index for each hole within the main positions array. ```javascript // Polygon with a hole starting at vertex 4 earcut([0, 0, 100, 0, 100, 100, 0, 100, 20, 20, 80, 20, 80, 80, 20, 80], [4]); // returns [3, 0, 4, 5, 4, 0, 3, 4, 7, 5, 0, 1, 2, 3, 7, 6, 5, 1, 2, 7, 6, 6, 1, 2] ``` -------------------------------- ### Geoid Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/geoid/api-reference/geoid.md Creates an instance of the Geoid class. Requires an options object containing the binary buffer of the earth gravity model file. ```APIDOC ## Constructor Create a `Geoid` instance. ### Parameters #### Options - **data** (binary buffer) - Required - Binary buffer of the earth gravity model file (e.g., from a .pgm file). ### Description Initializes the Geoid model with earth gravity data. ``` -------------------------------- ### Get Transformation Matrix Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Obtain a 4x4 matrix that transforms coordinates from the pose-relative system to the parent coordinate system. The pose-relative system has its origin at the pose's position and its axes aligned with the pose's rotation. ```javascript pose.getTransformationMatrix() ``` -------------------------------- ### Vector3 Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector3.md Initializes a new Vector3 instance. It can be initialized with x, y, and z components, or as a zero vector. ```APIDOC ## constructor(x = 0, y = 0, z = 0) ### Description Initializes a new Vector3 instance with optional x, y, and z components. ### Parameters - **x** (Number) - The x component of the vector. Defaults to 0. - **y** (Number) - The y component of the vector. Defaults to 0. - **z** (Number) - The z component of the vector. Defaults to 0. ``` -------------------------------- ### Import and Use cutPolylineByMercatorBounds Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/cut-polyline-by-mercator-bounds.md Import the function and use it with sample positions and options. The function returns a new array of positions representing the split polyline. ```javascript import {cutPolylineByMercatorBounds} from '@math.gl/polygon'; cutPolylineByMercatorBounds([-10, -10, 10, 10, 30, -10], {size: 2, gridResolution: 10}); // returns [-10, -10, 0, 0, 10, 10, 20, 0, 30, -10] ``` -------------------------------- ### Import and Use clipPolygon Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/clip-polygon.md Import the clipPolygon function and use it to clip a polyline against a bounding box. Ensure the correct size parameter is used for the input positions. ```javascript import {clipPolygon} from '@math.gl/polygon'; clipPolyline([-10, -10, 10, 10, 30, -10, -10, -10], [0, 0, 20, 20], {size: 2}); // returns [0, 0, 10, 10, 20, 0, 0, 0] ``` -------------------------------- ### Disable Debug Checks in math.gl Source: https://github.com/visgl/math.gl/blob/master/docs/developer-guide/performance.md Disable debug checks to improve performance. When enabled, math.gl checks objects after every operation, which has a modest performance impact. This example shows how to disable and then re-enable debug checks. ```javascript import {configure, Vector2} from '@math.gl/core'; configure({debug: false}); let vector = new Vector2(NaN, NaN); // Initializes an "invalid" vector configure({debug: true}); let vector = new Vector2(NaN, NaN); // Now throws an error. The check ``` -------------------------------- ### Get Transformation Matrix From Another Pose Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Calculate a 4x4 matrix to transform coordinates from a second coordinate system (represented by otherPose) into the coordinate system of the current pose. This is useful when an object is represented in multiple coordinate systems. ```javascript pose.getTransformationMatrixFromPose(otherPose) ``` -------------------------------- ### Methods Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/spherical-coordinates.md Provides methods for initializing, manipulating, and converting SphericalCoordinates objects. ```APIDOC ## Methods ### constructor ```js SphericalCoordinates({phi = 0, theta = 0, radius = 1.0}) SphericalCoordinates({bearing = 0, pitch = 0, altitude = 1.0}) SphericalCoordinates({longitude = 0, latitude = 0, z = 1.0}) ``` - phi=0 - rotation around X (latitude) - theta=0 - rotation around Y (longitude) - radius=1 - Distance from center ### set `set(radius, phi, theta)` ### clone `clone()` ### copy `copy(other)` ### fromLngLatZ `fromLngLatZ([lng, lat, z])` ### fromVector3 `fromVector3(v)` ### makeSafe `makeSafe()` // restrict phi to be betwee EPS and PI-EPS ### toVector3 `toVector3(center = [0, 0, 0])` // TODO - add parameter for orientation of sphere? up vector etc? ### check ``` -------------------------------- ### exactEquals Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Compares this pose with another pose for exact equality. ```APIDOC ## exactEquals `pose.exactEquals(otherPose)` ``` -------------------------------- ### Create BoundingSphere from Corner Points Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/bounding-sphere.md Creates a bounding sphere that tightly encloses an axis-aligned bounding box defined by two corner points. Ensure the BoundingSphere class is imported. ```javascript import {BoundingSphere} from '@math.gl/culling'; cont sphere = new BoundingSphere().fromCornerPoints( [-0.5, -0.5, -0.5], [0.5, 0.5, 0.5] ); ``` -------------------------------- ### projectFlat(lngLat, scale) Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/api-reference/web-mercator-viewport.md Projects longitude and latitude onto Web Mercator coordinates. This is useful for converting geographical coordinates to a flat, projected map system. ```APIDOC ## projectFlat(lngLat, scale) ### Description Project longitude and latitude onto Web Mercator coordinates. ### Parameters #### Path Parameters - `lngLat` (Array) - Required - map coordinates, `[lng, lat]` - `scale` (number) - Optional - Default: `this.scale` - Web Mercator scale ### Returns - `[x, y]`, representing Web Mercator coordinates. ``` -------------------------------- ### Usage Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/spherical-coordinates.md Import and create SphericalCoordinates objects using various initialization options. ```APIDOC ## Usage ```js import {SphericalCoordinates} from '@math.gl/core'; ``` Creating a SphericalCoordinates object ```js const spherical = new SphericalCoordinates({phi: 0, theta: 0}); const spherical = new SphericalCoordinates({pitch: 0, bearing: 0}); const spherical = new SphericalCoordinates({longitude: 0, latitude: 0}); ``` Converting to a direction `Vector3` ```js const direction = new SphericalCoordinates().toVector3(); ``` Manipulating spherical coordinates; ```js spherical.bearing += 3; // Add three degrees to bearing spherical.theta -= Math.PI / 4; // Subtract PI/4 radians from theta. ``` ``` -------------------------------- ### perspective() Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Generates a perspective projection matrix with the given bounds. The frustum far plane can be infinite. ```APIDOC ## perspective() ### Description Generates a perspective projection matrix with the given bounds. The frustum far plane can be infinite. ### Parameters - `fovy` (number) - Vertical field of view in radians (default is 45 degrees specified in radians) - `aspect` (number) - Aspect ratio. typically viewport width/height - `near` (number) - Near bound of the frustum - `far` (number|Infinity) - Far bound of the frustum ### Example ```javascript matrix4.perspective({ fovy: 45 * Math.PI / 180, aspect: 1, near: 0.1, far: 500 }) ``` ``` -------------------------------- ### Vector4 Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector4.md Creates a new Vector4 instance. Initializes with zeros if no arguments are provided. ```APIDOC ## constructor(x?: number, y?: number, z?: number, w?: number) `new Vector4(x = 0, y = 0, z = 0, w = 0)` Creates a new, empty `Vector4` ``` -------------------------------- ### Create an Empty Matrix3 Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix3.md Instantiate a new Matrix3 object without any initial values. ```javascript new Matrix3() ``` -------------------------------- ### Create Frustum Matrix Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Generate a frustum projection matrix with specified bounds. The far plane can be infinite. ```javascript matrix4.frustum({left, right, bottom, top, near, far}) ``` -------------------------------- ### Create Perspective Projection Matrix Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/matrix4.md Generate a perspective projection matrix using specified field of view, aspect ratio, and near/far clipping planes. ```javascript const projectionMatrix = new Matrix4().perspective({fov, aspect, near, far}); ``` -------------------------------- ### Create a Plane instance Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/plane.md Instantiate a Plane object representing the x=0 plane. Ensure the normal vector is normalized. ```javascript import {Plane} from '@math.gl/culling'; const plane = new Plane([1, 0, 0], 0.0); ``` -------------------------------- ### Pose Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Initializes a new Pose object. It can be constructed using individual position and rotation components or by providing Vector3 and Euler objects. ```APIDOC ## constructor ``` new Pose({x, y, z, roll, pitch, yaw}); new Pose({position, orientation}); ``` - `x`, `y`, `z` - position - `roll`, `pitch`, `yaw` - rotation in radians - `position` - `Vector3` or array of 3 that represents the position - `orientation` - `Euler` or array of 4 that represents the rotation ``` -------------------------------- ### project Method Source: https://github.com/visgl/math.gl/blob/master/docs/modules/web-mercator/api-reference/web-mercator-viewport.md Projects geographical coordinates (longitude, latitude, and optionally elevation) to pixel coordinates on the screen. ```APIDOC ## project(lngLatZ, options) ### Description Projects latitude and longitude to pixel coordinates on screen. ### Parameters - **lngLatZ** (Array) - Required - Map coordinates, `[lng, lat]` or `[lng, lat, Z]` where `Z` is elevation in meters. - **options** (Object) - Optional - Named options. - **options.topLeft** (Boolean) - Optional - If `true` projected coords are top left, otherwise bottom left. Defaults to `true`. ### Returns - `[x, y]` or `[x, y, z]` in pixels coordinates. `z` is pixel depth. ### Remarks - By default, returns top-left coordinates suitable for canvas/SVG type rendering. ``` -------------------------------- ### add Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/quaternion.md Adds two quaternions component-wise. ```APIDOC ## add `add(a, b)` Adds two quaternions. ``` -------------------------------- ### Quaternion Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/quaternion.md Initializes a new Quaternion instance. It can be initialized with x, y, z, and w components, defaulting to x=0, y=0, z=0, w=1. ```APIDOC ## constructor `constructor(x = 0, y = 0, z = 0, w = 1)` Initializes a new Quaternion instance with the given components. ``` -------------------------------- ### Update Vector4 Elements Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/vector4.md Shows how to update the components of an existing Vector4 instance. ```javascript vector.set(1, 2, 3, 4); ``` -------------------------------- ### AxisAlignedBoundingBox Constructor Source: https://github.com/visgl/math.gl/blob/master/docs/modules/culling/api-reference/axis-aligned-bounding-box.md Initializes a new AxisAlignedBoundingBox instance. It can be created using two corner points or from a collection of points. ```APIDOC ## constructor(minimum = [0, 0, 0], maximum = [0, 0, 0]) ### Description Initializes a new AxisAlignedBoundingBox instance. ### Parameters #### Path Parameters - **minimum** (Vector3) - Optional - The minimum corner of the box, i.e. `[xMin, yMin, zMin]`. - **maximum** (Vector3) - Optional - The maximum corner of the box, i.e. `[xMax, yMax, zMax]`. ``` -------------------------------- ### Formatting MathArray to String with Config Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/math-array.md Converts the MathArray to a string representation using a provided configuration object for custom formatting. ```javascript array.formatString(config) ``` -------------------------------- ### fromArray Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/math-array.md Initializes the MathArray from a standard JavaScript array. ```APIDOC ## fromArray ### Description Initializes the MathArray from a standard JavaScript array. ### Method `fromArray(array, offset = 0)` ### Parameters #### Path Parameters - **array** (number[]) - Required - The source array. - **offset** (number) - Optional - The starting offset in the source array. ``` -------------------------------- ### Euler Methods Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/euler.md Provides methods for converting to and from different rotation representations, setting angles, and copying values. ```APIDOC ## fromRollPitchYaw(roll, pitch, yaw) ### Description Sets the Euler angles from roll, pitch, and yaw values, typically used with the ZYX rotation order. ### Parameters - **roll** (Number) - The roll angle. - **pitch** (Number) - The pitch angle. - **yaw** (Number) - The yaw angle. ``` ```APIDOC ## fromRotationMatrix(m, order = Euler.DefaultOrder) ### Description Sets the Euler angles from a rotation matrix. ### Parameters - **m** (Matrix4) - The rotation matrix. - **order** (Number) - The desired rotation order. Defaults to `Euler.DefaultOrder`. ``` ```APIDOC ## fromQuaternion(q, order) ### Description Sets the Euler angles from a quaternion. ### Parameters - **q** (Quaternion) - The quaternion. - **order** (String) - The rotation order. ``` ```APIDOC ## copy(array) ### Description Copies Euler angles from an array. If the array contains a fourth element, it preserves the current order. ### Parameters - **array** (Array) - The array containing the Euler angles. ``` ```APIDOC ## set(x = 0, y = 0, z = 0, order) ### Description Sets the three Euler angles and optionally the rotation order. If the order is not specified, the current order is preserved. ### Parameters - **x** (Number) - The x-component of the angle. - **y** (Number) - The y-component of the angle. - **z** (Number) - The z-component of the angle. - **order** (String) - The rotation order. ``` ```APIDOC ## toArray(array = [], offset = 0) ### Description Converts the Euler angles to an array. Does not copy the orientation element. ### Parameters - **array** (Array) - The array to store the angles in. Defaults to a new array. - **offset** (Number) - The offset in the array to start writing at. Defaults to 0. ### Returns - Array - The array containing the Euler angles. ``` ```APIDOC ## toArray4(array = [], offset = 0) ### Description Converts the Euler angles to an array, including the orientation element. ### Parameters - **array** (Array) - The array to store the angles in. Defaults to a new array. - **offset** (Number) - The offset in the array to start writing at. Defaults to 0. ### Returns - Array - The array containing the Euler angles and orientation. ``` ```APIDOC ## toVector3(optionalResult) ### Description Converts the Euler angles to a Vector3. ### Parameters - **optionalResult** (Vector3) - An optional Vector3 to store the result in. ### Returns - Vector3 - A Vector3 representing the Euler angles. ``` ```APIDOC ## fromVector3(v, order) ### Description Sets the Euler angles from a Vector3. ### Parameters - **v** (Vector3) - The Vector3 containing the angles. - **order** (String) - The rotation order. ``` ```APIDOC ## fromArray(array, offset = 0) ### Description Sets the Euler angles from an array. ### Parameters - **array** (Array) - The array containing the angles. - **offset** (Number) - The offset in the array to start reading from. Defaults to 0. ``` ```APIDOC ## getRotationMatrix(m = new Matrix4()) ### Description Returns a rotation matrix corresponding to the Euler angles. ### Parameters - **m** (Matrix4) - An optional Matrix4 to store the result in. Defaults to a new Matrix4. ### Returns - Matrix4 - A rotation matrix. ``` ```APIDOC ## getQuaternion() ### Description Returns a quaternion corresponding to the Euler angles. ### Returns - Quaternion - A quaternion representing the rotation. ``` -------------------------------- ### SphericalCoordinates Methods Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/spherical-coordinates.md Illustrates the signatures for common methods of the SphericalCoordinates class, including set, clone, copy, fromLngLatZ, fromVector3, makeSafe, toVector3, and check. ```javascript `set(radius, phi, theta)` ``` ```javascript `clone()` ``` ```javascript `copy(other)` ``` ```javascript `fromLngLatZ([lng, lat, z])` ``` ```javascript `fromVector3(v)` ``` ```javascript `makeSafe()` ``` ```javascript // restrict phi to be betwee EPS and PI-EPS ``` ```javascript `toVector3(center = [0, 0, 0])` ``` ```javascript // TODO - add parameter for orientation of sphere? up vector etc? ``` ```javascript `check()` ``` -------------------------------- ### SphericalCoordinates Constructor Overloads Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/spherical-coordinates.md Demonstrates the different ways to construct a SphericalCoordinates object using various parameter sets. Default values are provided for optional parameters. ```javascript SphericalCoordinates({phi = 0, theta = 0, radius = 1.0}) ``` ```javascript SphericalCoordinates({bearing = 0, pitch = 0, altitude = 1.0}) ``` ```javascript SphericalCoordinates({longitude = 0, latitude = 0, z = 1.0}) ``` -------------------------------- ### equals Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Compares this pose with another pose for equality. ```APIDOC ## equals `pose.equals(otherPose)` ``` -------------------------------- ### Compare Poses for Equality Source: https://github.com/visgl/math.gl/blob/master/docs/modules/core/api-reference/pose.md Check if two Pose objects are equal using the equals method. For exact comparison, use exactEquals. ```javascript pose.equals(otherPose) ``` -------------------------------- ### cutPolygonByMercatorBounds Function Signature Source: https://github.com/visgl/math.gl/blob/master/docs/modules/polygon/api-reference/cut-polygon-by-mercator-bounds.md Shows the expected arguments for the cutPolygonByMercatorBounds function, including positions, optional hole indices, and configuration options. ```javascript cutPolygonByMercatorBounds(positions, holeIndices, [options]); ```