{"id":19621325,"url":"https://github.com/commenthol/affinefit","last_synced_at":"2025-04-28T03:32:16.778Z","repository":{"id":57174020,"uuid":"55812089","full_name":"commenthol/affinefit","owner":"commenthol","description":"Fit an affine transformation to given points","archived":false,"fork":false,"pushed_at":"2021-08-07T10:51:20.000Z","size":14,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-18T14:51:51.327Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commenthol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-08T21:57:50.000Z","updated_at":"2025-01-07T08:07:05.000Z","dependencies_parsed_at":"2022-09-02T11:21:33.682Z","dependency_job_id":null,"html_url":"https://github.com/commenthol/affinefit","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Faffinefit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Faffinefit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Faffinefit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commenthol%2Faffinefit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commenthol","download_url":"https://codeload.github.com/commenthol/affinefit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251246236,"owners_count":21558761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T11:22:22.273Z","updated_at":"2025-04-28T03:32:16.234Z","avatar_url":"https://github.com/commenthol.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# affinefit\n\n\u003e Fit an affine transformation to given points\n\n[![NPM version](https://badge.fury.io/js/affinefit.svg)](https://www.npmjs.com/package/affinefit/)\n\n## Table of Contents\n\n\u003c!-- !toc (minlevel=2 omit=\"Table of Contents\") --\u003e\n\n* [Description](#description)\n  * [Usage](#usage)\n  * [Example](#example)\n* [Contribution and License Agreement](#contribution-and-license-agreement)\n* [License](#license)\n* [References](#references)\n\n\u003c!-- toc! --\u003e\n\n## Description\n\nFit an affine transformation to given points\n\nThis 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.\n\nThe original algorithm from Jarno Elonen \u003celonen@iki.fi\u003e was translated from python to javascript and can be found at [python affine-fit][].\n\n### Usage\n\n```js\nvar affineFit = require('affinefit')\n\nvar res\nvar fromPts = [[1, 1], [1, 2], [2, 2], [2, 1]]   // a 1x1 rectangle\nvar toPts   = [[4, 4], [6, 6], [8, 4], [6, 2]]   // scaled x 2, rotated 45 degrees and translated\n\nvar trn = affineFit(fromPts, toPts)\n\nres = trn([1, 2])\n//\u003e [ 5.999999999999998, 5.999999999999999 ]\nres = trn([1.5, 1.5])\n//\u003e [ 6, 4 ]\n\n// to obtain the matrix in \"Row echelon form\" use `trn.M`\nvar matrix = trn.M\n//\u003e [ [ 1, 0, 0, 2, -2 ],\n//\u003e   [ 0, 1, 0, 2,  2 ],\n//\u003e   [ 0, 0, 1, 0,  4 ] ]\n```\n\n### Example\n\nRun the example from `./test/example.js` which transforms the given svg image\n\n\u003cimg src=\"./test/rectangles.svg\" style=\"border: 1px #ccc dashed\"/\u003e\n\u003cimg src=\"./test/transformed.svg\" style=\"border: 1px #ccc dashed\"/\u003e\n\nusing the transform\n\n`[[1, 1], [1, 2], [2, 2], [2, 1]] =\u003e [[4, 4], [6, 6], [8, 4], [6, 2]]`\n\n## Contribution and License Agreement\n\nIf you contribute code to this project, you are implicitly allowing your\ncode to be distributed under the CC0 1.0 license. You are also implicitly\nverifying that all code is your original work or correctly attributed\nwith the source of its origin and licence.\n\n## License\n\nCC0 1.0 Universal Public Domain Dedication\n\nSee [LICENSE][] for more info.\n\n## References\n\n\u003c!-- !ref --\u003e\n\n* [LICENSE][LICENSE]\n* [python affine-fit][python affine-fit]\n\n\u003c!-- ref! --\u003e\n\n[LICENSE]: ./LICENSE\n[python affine-fit]: http://elonen.iki.fi/code/misc-notes/affine-fit/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Faffinefit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommenthol%2Faffinefit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommenthol%2Faffinefit/lists"}