大网数据广告活动
Web 标准与前端开发

DOMMatrixReadOnly: fromFloat64Array() static method

· 52CE 我爱测

The **`fromFloat64Array()`** static method of the DOMMatrixReadOnly interface creates a new DOMMatrixReadOnly object given an array of double-precision (64-bit) floating-point values.

Geometry Interfaces

The fromFloat64Array() static method of the DOMMatrixReadOnly interface creates a new DOMMatrixReadOnly object given an array of double-precision (64-bit) floating-point values.

If the array has 6 values, the result is a 2D matrix; if the array has 16 values, the result is a 3D matrix. Otherwise, a TypeError exception is thrown.

Syntax

DOMMatrixReadOnly.fromFloat64Array(array)

Parameters

  • array
    • : A Float64Array with 6 or 16 elements in column-major order.

Return value

A DOMMatrixReadOnly object.

Exceptions

  • TypeError
    • : Thrown if the length of the array parameter is not 6 or 16.

Examples

Creating a 2D matrix from a Float64Array

This example creates a 2D matrix from a 6-element Float64Array.

const float64Array = new Float64Array([1, 0, 0, 1, 10, 20]);
const matrix2D = DOMMatrixReadOnly.fromFloat64Array(float64Array);

console.log(matrix2D.toString());
// Output: matrix(1, 0, 0, 1, 10, 20)

console.log(matrix2D.is2D);
// Output: true

console.log(matrix2D.e, matrix2D.f);
// Output: 10 20

Creating a 3D matrix from a Float64Array

This example creates a 3D matrix from a 16-element Float64Array.

const float64Array = new Float64Array([
  1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 20, 30, 1,
]);
const matrix3D = DOMMatrixReadOnly.fromFloat64Array(float64Array);

console.log(matrix3D.is2D);
// Output: false

console.log(matrix3D.m41, matrix3D.m42, matrix3D.m43);
// Output: 10 20 30

Specifications

Browser compatibility

See also

  • DOMMatrixReadOnly/DOMMatrixReadOnly
  • DOMMatrixReadOnly.toFloat32Array()
  • DOMMatrixReadOnly.toFloat64Array()
  • DOMMatrixReadOnly.fromFloat32Array_static
  • DOMMatrixReadOnly.fromMatrix_static

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。