Coder Social home page Coder Social logo

axelpale / nudged Goto Github PK

View Code? Open in Web Editor NEW
63.0 4.0 6.0 3.66 MB

Estimate scale, rotation, and translation between two sets of 2D points. For multitouch, calibration, pattern recognition, and more.

License: MIT License

JavaScript 100.00%
estimation geometry multitouch optimization transformation

nudged's Issues

Use Transform.prototype

Currently the methods are bound to this during construction. Due to frequent use of immutable transformations, it is probably better to bind to prototype.

Support for TypeScript

The lib could be more friendly for TypeScript users.

@lsps9150414 Could you share a rough insight on how should it be done? Is it enough to have one index.d.ts file in the root of the project, or should lib/ and each directory under it, like lib/point/ and lib/transform/ also have their own index.d.ts files? Thanks for any guidance on this.

Provide more prebuilt transformations

Currently IDENTITY is the only one. Prebuilt transformations come handy in tests and during development.

For example nudged.Transform.CW90, .CCW90, .X2

I just want to say thank you

Working on gesture handling and this lib literally saved me tons of hours. Please accept my worship ๐Ÿ™‡๐Ÿปโ€โ™‚๏ธ ๐Ÿ™‡๐Ÿปโ€โ™‚๏ธ ๐Ÿ™‡๐Ÿปโ€โ™‚๏ธ

Prevent singular estimates

Let the domain be [[-1,0],[1,0]] and the range [[0,-1],[0,1]]. The in other words the plane rotates 90 degrees.

Let us apply TS estimator. The estimate becomes { a: 0, b: 0, x: 1, y: 0 } which means that all points map to [1,0].

This is optimal behavior in a sense that it maps the domain as close to the range as possible. However, is this desired behavior? The singularity causes information loss. It maps the whole space to a point and therefore it is not anymore an affine transformation but an affine map. Should we promise that the estimates are always true affine transformations?

An approach that would satisfy the requirement is to fall back to translation if the linear transformation becomes singular. However, this causes a discontinuity at rotation angles near 90 degrees.

Another approach would always estimate a TSR and then extract the required part, TS.

Misleading documentation for nudged.Transform#get_matrix()

Documentation says that nudged.Transform#get_matrix() returns affine matrix in the following form (which would be incorrect if it did):

|s  -r  tx|
|r   s  ty|
|0   0   1|

In fact, the function returns proper matrix (contrary to the doc) which is:

|s*cos -s*sin  tx|
|s*sin  s*cos  ty|
|0      0      1|

Allow transformation type I

Allow identity transformation type. It would help users because the calling code can call nudged even when no estimation needs to be done.

Bug in estimateTR

A single domain point and a range point should not cause rotation. However in v1.3.0 the following happens:

> var domain = [[0.21255673222390348, 0.20282314674735248]]
> var range = [[0.20801815431164927, 0.19818456883509827]]
> var tr = nudged.estimateTR(domain, range)
> tr.getScale()
1
> tr.getRotation()
3.141592653589793
> tr.getTranslation()
[ 0.42057488653555275, 0.40100771558245074 ]
> tr.getMatrix()
{ a: -1,
  b: 0,
  c: -0,
  d: -1,
  e: 0.42057488653555275,
  f: 0.40100771558245074 }

What causes this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.