Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
affinefit
Advanced tools
Readme
Fit an affine transformation to given points
Fit an affine transformation to given points
This module finds, by least squares fitting, an affine transformation that (approximately) transforms given set of points/vertices/vector to another. It works with arbitrary dimensional points and requires at least dim points, when your points are dim-dimensional.
The original algorithm from Jarno Elonen elonen@iki.fi was translated from python to javascript and can be found at python affine-fit.
var affineFit = require('affinefit')
var res
var fromPts = [[1, 1], [1, 2], [2, 2], [2, 1]] // a 1x1 rectangle
var toPts = [[4, 4], [6, 6], [8, 4], [6, 2]] // scaled x 2, rotated 45 degrees and translated
var trn = affineFit(fromPts, toPts)
res = trn([1, 2])
//> [ 5.999999999999998, 5.999999999999999 ]
res = trn([1.5, 1.5])
//> [ 6, 4 ]
// to obtain the matrix in "Row echelon form" use `trn.M`
var matrix = trn.M
//> [ [ 1, 0, 0, 2, -2 ],
//> [ 0, 1, 0, 2, 2 ],
//> [ 0, 0, 1, 0, 4 ] ]
Run the example from ./test/example.js
which transforms the given svg image
using the transform
[[1, 1], [1, 2], [2, 2], [2, 1]] => [[4, 4], [6, 6], [8, 4], [6, 2]]
If you contribute code to this project, you are implicitly allowing your code to be distributed under the CC0 1.0 license. You are also implicitly verifying that all code is your original work or correctly attributed with the source of its origin and licence.
CC0 1.0 Universal Public Domain Dedication
See LICENSE for more info.
FAQs
Fit an affine transformation to given points
The npm package affinefit receives a total of 8 weekly downloads. As such, affinefit popularity was classified as not popular.
We found that affinefit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.