Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Estimate scale, rotation, and translation between two sets of 2D points. Applicable for example to multi-touch gestures and eye tracker calibration.
Mathematically speaking, nudged is an optimal least squares estimator for affine transformation matrices with uniform scaling, rotation, and translation and without reflection and shearing. The estimation has time complexity of O(n) that consists of 6n+22 multiplications and 11n+19 additions, where n is the cardinality (size) of the point sets.
npm install nudged
// Points before and after transformation i.e. the training data
var domain = [[0,0], [2,0], [ 1,2]];
var range = [[1,1], [1,3], [-1,2]];
// Compute optimal tranformation based the points
var trans = nudged.estimate(domain, range);
trans.getMatrix()
// [[0,-1, 1],
// [1, 0, 1],
// [0, 0, 1]]
// Apply the transformation to other points
trans.transform([2,2])
// [-1,3]
// Get rotation in radians
trans.getRotation()
// 1.5707... = π / 2
// Get scaling multiplier
trans.getScale()
// 1.0
// Get horizontal and vertical movement
trans.getTranslation()
// [1, 1]
Parameters
The domain and range should have equal length. Different lengths are allowed but additional points in the longer array are ignored in the estimation.
Return new nudged.Transform(...) instance.
Contains the module version string equal to the version in package.json.
An instance returned by the nudged.estimate(...).
In addition to the methods below, it has properties s, r, tx, ty that define the augmented transformation matrix:
|s -r tx|
|r s ty|
|0 0 1|
Return an array of transformed points or single point if a point was given. For example:
trans.transform([1,1]) // [2,2]
trans.transform([[1,1]]) // [[2, 2]]
trans.transform([[1,1], [2,3]]) // [[2,2], [3,4]]
Return an 3x3 augmented transformation matrix in the following array format:
[[s,-r, tx],
[r, s, ty],
[0, 0, 1]]
Return rotation in radians.
Return scaling multiplier, e.g. 0.33
for a threefold shrink.
Return [tx, ty]
where tx
and ty
denotes movement along x-axis and y-axis accordingly.
[0.2.0] – 2015-10-19
estimate
Transform
: getMatrix
, getRotation
, getScale
, getTranslation
.FAQs
Affine transformation estimator e.g. for multi-touch gestures and calibration
The npm package nudged receives a total of 109 weekly downloads. As such, nudged popularity was classified as not popular.
We found that nudged demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.