dreamer-common-def
v1.0.5
Published
## 安装包(前后端通用)
Downloads
4
Maintainers
Readme
通用矩阵计算库
安装包(前后端通用)
yarn add dreamer-common-def
包说明
//生成随机数
declare const getRandom: (arr: number[], isInt?: boolean) => number;
//数组转置
declare const T: (source: number[][]) => number[][];
//矩阵点乘
declare const getAxis: (left: number[][], right?: number[][], isPoint?: boolean) => number[][];
//4*4 方阵转matrix2d 数组
declare const matrix2D: (source: number[][]) => number[];
//4*4 方阵转matrix3d 数组
declare const matrix3D: (source: number[][]) => number[];
//4*4 方阵转css 字符串
declare const matrixCss: (source: number[][]) => string;
//计算行列式
declare const determinant: (source: number[][]) => number;
//计算伴随矩阵
declare const adjoint: (param: number[][], tag?: boolean) => number[][];
//透视矩阵
declare function perspectiveNO(fovy: number, aspect: number, near: number, far: number): number[][];
//方法装饰器
declare const runtimeDecorator: () => MethodDecorator;
//导出模块
export { getRandom, T, getAxis, matrix2D, matrix3D, matrixCss, determinant, adjoint, perspectiveNO, runtimeDecorator, };
在html使用data url
<script type="module">
import {
getRandom,
T,
getAxis,
matrix2D,
matrix3D,
matrixCss,
determinant,
adjoint,
perspectiveNO,
runtimeDecorator,
} from 'data:text/javascript;charset=utf-8;base64,dmFyIGU9e2Q6KG4sdCk9Pntmb3IodmFyIHIgaW4gdCllLm8odCxyKSYmIWUubyhuLHIpJiZPYmplY3QuZGVmaW5lUHJvcGVydHkobixyLHtlbnVtZXJhYmxlOiEwLGdldDp0W3JdfSl9LG86KGUsbik9Pk9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChlLG4pfSxuPXt9O2UuZChuLHtUOigpPT5yLHVqOigpPT5mLEdIOigpPT5jLGRkOigpPT5vLHNaOigpPT50LHdoOigpPT5sLGhEOigpPT5oLEMyOigpPT5hLFhfOigpPT5zLHZJOigpPT5pfSk7Y29uc3QgdD1mdW5jdGlvbihlLG49ITEpe2NvbnN0IHQ9TWF0aC5taW4oLi4uZSkscj1NYXRoLm1heCguLi5l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4wOyl7Y29uc3QgZT1bXTtmb3IobGV0IG49MDtuPDQ7KytuKWUucHVzaChoLnBvcCgpKTt5aWVsZCBlfX0pLHthcHBseSguLi5lKXtjb25zdCBuPVsuLi5SZWZsZWN0LmFwcGx5KC4uLmUpXTtyZXR1cm4gcihuKX19KSgpfWNvbnN0IGk9ZnVuY3Rpb24oKXtyZXR1cm4oZSxuLHQpPT57dC52YWx1ZT1uZXcgUHJveHkodC52YWx1ZSx7YXBwbHk6ZnVuY3Rpb24oLi4uZSl7Y29uc29sZS5sb2coYD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PVNUQVJUOiAke259ID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PWApO3RyeXtyZXR1cm4gY29uc29sZS5sb2coImVtYWlsOiAiLCJjaGVuX3NoZW5nZGFAeWVhaC5uZXQiKSxjb25zb2xlLmxvZygidGltZTogIixuZXcgRGF0ZSksY29uc29sZS5sb2coImFyZ3M6ICIsZSksUmVmbGVjdC5hcHBseSguLi5lKX1jYXRjaChlKXtjb25zb2xlLmVycm9yKGUpfWZpbmFsbHl7Y29uc29sZS5sb2coYD09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09RU5EOiAke259ID09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PWApfX19KX19O3ZhciBnPW4uVCx1PW4udWoseT1uLkdILHA9bi5kZCx3PW4uc1osZD1uLndoLG09bi5oRCx4PW4uQzIsQT1uLlhfLFA9bi52STtleHBvcnR7ZyBhcyBULHUgYXMgYWRqb2ludCx5IGFzIGRldGVybWluYW50LHAgYXMgZ2V0QXhpcyx3IGFzIGdldFJhbmRvbSxkIGFzIG1hdHJpeDJELG0gYXMgbWF0cml4M0QseCBhcyBtYXRyaXhDc3MsQSBhcyBwZXJzcGVjdGl2ZU5PLFAgYXMgcnVudGltZURlY29yYXRvcn07'
const matrix = [
[1, 1, 0],
[2, 4, 0],
[0, 0, 1],
];
const amatrix = adjoint( matrix )
const pro = getAxis( matrix, amatrix )
console.log( pro )
</script>