npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ishikawa-masashi/math

v0.5.0

Published

`@ishikawa-masashi/math` is a collection of vector, matrix and quaternion classes written in Typescript with *no dependencies*.

Downloads

52

Readme

@ishikawa-masashi/math: A Typescript vector and matrix math library

@ishikawa-masashi/math is a collection of vector, matrix and quaternion classes written in Typescript with no dependencies.

How to install it

Using npm or yarn

npm install --save ts-matrix
yarn add ts-matrix

Or add the unpkg cdn link to your html

<script src="https://unpkg.com/ts-matrix">

The library is built as an ECMAScript module (.mjs file), but it also exports a UMD version if needed.

Usage

Import the module, from Typescript or ES6 javascript.

import { Vector3, Matrix } from '@ishikawa-masashi/math';

Then use the methods as you want :)

const v1 = new Vector([1, 2]);
const v2 = new Vector([3, 1]);
v1.add(v2);
// ==> [4, 3]

Most operation return a new Vector instance.

If you use typescript, the declarations files are available with self documentation.


Documentation

Vectors

Instance methods

| method | description | |--------|-------------| | at(row: number) | Get the value of a cell | | rows() | Returns Vector's size | | values() | Returns Vector values as an array | | reset() | Sets all matrix values to 0 | | addAValue() | Add a new 0 to the Vector | | addARow() | Add a new empty row to the Matrix | | equals(vector: Vector) | Checks equality between two vectors | | negate() | Negates the Vector (change all cells arithmetic sign). Returns a new instance. | | length() | Returns the vectors length | | squaredLength() | Returns the vectors squared length | | add(vector: Vector) | Adds all given values to the current Vector instance. Both vectors must have the same dimension. Mutates current instance. | | substract(vector: Vector) | Substracts all given values to the current Vector instance. Both vectors must have the same dimension. Mutates current instance. | | multiply(vector: Vector) | Multiplies all given values to the current Vector instance. Both vectors must have the same dimension. Mutates current instance. | | divide(vector: Vector) | Divides all given values to the current Vector instance. Both vectors must have the same dimension. Mutates current instance. | | scale(scale: number) | Multiply all vector values by the given scale. Mutates current instance. | | normalize(scale: number) | Computes the normalized Vector. Mutates current instance. | | dot(vector: Vector) | Computes the dot product between two Vectors. | | cross(vector: Vector) | Computes the cross product between two Vectors. Returns new instance | | mix(vector: Vector, time: number) | Computes the mix product between two Vectors. Returns new instance |

Static methods

| method | description | |--------|-------------| | get360angle(VectorA: Vector, VectorB: Vector) | Compute the angle between two Vectors. Both vectors must be of dimension 3 exactly. The returned angle is signed, thus -180º < angle < 180º |


Matrices

Instance methods

| method | description | |--------|-------------| | at(row: number, col: number) | Get the value of a cell | | rows() | Returns matrix rows as an array | | cols() | Returns matrix columns as an array | | values() | Returns matrix values as a bi-dimentional array | | reset() | Sets all matrix values to 0 | | addAColumn() | Add a new empty column to the Matrix | | addARow() | Add a new empty row to the Matrix | | equals(matrix: Matrix) | Checks equality between two matrices | | setAsIdentity() | Fills a squared matrix with the identity values (diagnonal 1) | | multiply(matrix: Matrix) | Multiply two matrices. Returns a new instance. | | determinant | Compute the determinant of the matrix. | | getCofactor(row: number, col: number) | Compute the cofactor of the matrix. Returns a new instance. | | transpose() | Transpose the matrix. Returns a new instance. | | inverse() | Inverse the matrix. Returns a new instance. |

Static methods

| method | description | |--------|-------------| | identity(dimension: number) | Returns a new squared identity Matrix |

Contributing

Any contribution is welcome, whether it is an issue, PullRequest, or just a comment!

Made with love by Florent Catiau-Tristant (@kapcash)