Chrome Extension: TypedArray to Matrix table All In One
Chrome Extension: TypedArray to Matrix table All In One
difficulty:
Medium/ 难度:中等
glMatrix
TypedArray
ArrayBuffer
Flaot32Array(16)
console.table()
Unit Matrix / 单位矩阵
demos
import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
console.log(`glMatrix =`, glMatrix);
console.log(`mat4 =`, mat4);
// Unit Matrix / 单位矩阵
let matrix4Uint = mat4.create()
console.log(matrix4Uint);
let arr2 = [];
let temp = [];
for(let i = 0; i < matrix4Uint.length; i++) {
temp.push(matrix4Uint[i]);
if((i + 1) % 4 === 0) {
arr2.push(temp);
temp = [];
}
}
console.log(arr2);
console.table(arr2);
import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
console.log(`glMatrix =`, glMatrix);
console.log(`mat4 =`, mat4);
// Unit Matrix / 单位矩阵
let matrix4Uint = mat4.create()
console.log(matrix4Uint);
let arr2 = [];
let temp = [];
for(let i = 1; i <= matrix4Uint.length; i++) {
console.log(`i =`, i, `matrix4Uint[i-1] =`, matrix4Uint[i-1]);
temp.push(matrix4Uint[i - 1]);
if(i === 16) {
console.log(`temp`, temp);
}
if(i % 4 === 0) {
arr2.push(temp);
temp = [];
}
}
console.log(arr2);
console.table(arr2);

import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
console.log(`glMatrix =`, glMatrix);
console.log(`mat4 =`, mat4);
// Unit Matrix / 单位矩阵
let matrix4Uint = mat4.create()
console.log(matrix4Uint);
let arr2 = [];
let temp = [];
for(let i = 0; i < matrix4Uint.length; i++) {
temp.push(matrix4Uint[i]);
if((i + 1) % 4 === 0) {
arr2.push(temp);
temp = [];
}
}
console.log(arr2);
// console.table(arr2);
function ArrObj(arr) {
for (let i = 0; i < arr.length; i++) {
this[`column${i}`] = arr[i];
}
}
let arrObjs = [];
for (let i = 0; i < arr2.length; i++) {
arrObjs.push(new ArrObj(arr2[i]));
}
console.table(arrObjs, ['column0', 'column1', 'column2', 'column3']);
// console.log(JSON.stringify(arr2, null, 4));
for(let i = 0; i < arr2.length; i++) {
let temp = [];
for (const arr of arr2) {
temp.push(arr[i]);
}
// console.log(temp);
console.log(`[`, temp.join(` `), `]`);
// console.log(temp.toString());
// console.log(JSON.stringify(temp, null, 4));
}

import {glMatrix, mat4 } from './gl-matrix-modules/esm/index.js';
console.log(`glMatrix =`, glMatrix);
console.log(`mat4 =`, mat4);
// Unit Matrix / 单位矩阵
let matrix4Uint = mat4.create()
console.log(matrix4Uint);
let arr2 = [];
let temp = [];
for(let i = 0; i < matrix4Uint.length; i++) {
temp.push(matrix4Uint[i]);
if((i + 1) % 4 === 0) {
arr2.push(temp);
temp = [];
}
}
console.log(arr2);
// console.table(arr2);
function ArrObj(arr) {
for (let i = 0; i < arr.length; i++) {
this[`column ${i + 1}`] = arr[i];
}
}
let arrObjs = [];
for (let i = 0; i < arr2.length; i++) {
arrObjs.push(new ArrObj(arr2[i]));
}
const columns = Object.keys((new ArrObj(arr2[0])));
console.log(columns);
console.table(arrObjs, columns);
// console.table(arrObjs, [...columns]);
// console.table(arrObjs, ['column0', 'column1', 'column2', 'column3']);
// console.log(JSON.stringify(arr2, null, 4));
for(let i = 0; i < arr2.length; i++) {
let temp = [];
for (const arr of arr2) {
temp.push(arr[i]);
}
// console.log(temp);
console.log(`[`, temp.join(` `), `]`);
// console.log(temp.toString());
// console.log(JSON.stringify(temp, null, 4));
}

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
console.table(data)
console.table(data, columns)
https://developer.mozilla.org/en-US/docs/Web/API/console/table_static
refs
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/19392545
未经授权禁止转载,违者必究!

浙公网安备 33010602011771号