Skip to main content

affine6p

The Python affine6p lib is to estimate affine transformation parameters between two sets of 2D points.:

| x' |   | a  b  p | | x |
| y' | = | c  d  q | | y |
| 1  |   | 0  0  1 | | 1 |
Example transformation

When the sets are more than three points, the lib estimate parameters with the least squares method.

In making this lib, I used a lot of ideas in nudged lib. Ref: https://github.com/axelpale/nudged-py

Install

Use pip:

pip install affine6p

Usage

You have lists of points for the original and converted of the transformation function to be estimated:

import affine6p
origin = [[0,0], [1,0], [0,1], [1,1]]
convert = [[0,0], [1,0], [0,1], [1,1.1]]
trans = affine6p.estimate(origin, convert)
trans.get_matrix()
# [[1.0, 0.0, 0.0],
# [0.050000000000000044, 1.05, -0.02499999999999991],
# [0, 0, 1]]
affine6p.estimate_error(trans, origin, convert)
# 0.025000000000000022

When the number of origin is 1, assume the following relationship:

a = d = 1 and b = c = 0

When the number of origin is 2, assume the following relationship as described in estimate_helmert.:

a = d and b = -c

You can access Transform class members.:

trans.a() # params[0]
trans.b() # params[1]
trans.c() # params[2]
trans.d() # params[3]
trans.p() # params[4]
trans.q() # params[5]
trans.get_matrix() # [[a, b, p], [c, d, q], [0, 0, 1]]
trans.get_rotation_x() # math.atan2(-b, a)
trans.get_rotation_y() # math.atan2(c, d)
trans.get_scale_x() # sqrt(a*a + b*b)
trans.get_scale_y() # sqrt(c*c + d*d)
trans.get_scale() # sqrt((scale_x*scale_x+scale_y*scale_y)*0.5)
trans.get_translation() # [p, q]
trans.params # [a, b, c, d, p, q]

You can apply transform or rotate to 2D point or points. The rotate means p = q = 0.:

trans.transform([0, 0])
trans.transform([[0, 0], [1, 1]])
point = [0, 0]
trans.transform_inv(point)
trans.rotate(point)
trans.rotate_inv(point)

Metadata

Release files for affine6p 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for affine6p 1.0.0
File Size Uploaded Provenance Actions
affine6p-1.0.0.tar.gz 4.1 kB Without provenance Details for affine6p-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for affine6p 1.0.0
File Interpreter ABI Platform Actions
affine6p-1.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for affine6p-1.0.0-py2.py3-none-any.whl

Total release size: 10.0 kB

Release files / affine6p-1.0.0.tar.gz

Download URL affine6p-1.0.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6cfdc0ab4ee663f66ba70b2204dd58805f64d2f1a12c6c92cb38bd1af1fa469c
BLAKE2b-256 checksum
How to use checksums
b663e9ca1ad9186afcffff177ebb42eea0cfa67f69954e82145e122a6228b8bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / affine6p-1.0.0-py2.py3-none-any.whl

Download URL affine6p-1.0.0-py2.py3-none-any.whl
Size 5.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
69c6653b9b4500f1ae283eb0d6438352cdd5e974bbf861d21d896d1846910644
BLAKE2b-256 checksum
How to use checksums
3389519563e336bf18f5fe44f9e0378d130c8c4e38d4ff357eeb9fd00369d52f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for affine6p 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page