@pelevesque/matrix-transformers
v0.0.5
Published
A collection of matrix transformation algorithms.
Downloads
15
Maintainers
Readme
matrix-transformers
A collection of matrix transformation algorithms.
Node Repository
https://www.npmjs.com/package/@pelevesque/matrix-transformers
Installation
npm install @pelevesque/matrix-transformers
Tests
Command | Description
---------------------------- | ------------
npm test
or npm run test
| All Tests Below
npm run cover
| Standard Style
npm run standard
| Coverage
npm run unit
| Unit Tests
Usage
Requiring the Module
const matrixTransformers = require('@pelevesque/matrix-transformers')
Requiring a Particular Transformation
const rotateMatrixClockwise = require('@pelevesque/matrix-transformers').rotate90
Available Transformations
- rotate90
- rotate180
- rotate270
- reflectHorizontally
- reflectVertically
Examples
const matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
const transformed = matrixTransformers.reflectHorizontally(matrix)
// result
transformed = [
[3, 2, 1],
[6, 5, 4],
[9, 8, 7]
]
const matrix = [
[1, 2],
[3, 4],
[5, 6]
]
const transformed = matrixTransformers.rotate270(matrix)
// result
transformed = [
[2, 4, 6],
[1, 3, 5]
]