Skip to main content

欧拉角、旋转矩阵、四元数、角轴及多格式矩阵计算基础库

Project description

transform-base

欧拉角、旋转矩阵、四元数、角轴及外参变换基础库,支持多种旋转顺序(XYZ/XZY/YXZ/YZX/ZXY/ZYX),并提供多输入格式解析、矩阵乘法/求逆/比较/方程求解的通用 API。

安装

pip install transform-base

功能特性

  • 角度归一化normalize_angle 将角度归一化到 [-180, 180]
  • 欧拉角 ↔ 旋转矩阵:支持 6 种旋转顺序(order),默认 ZYX
  • 旋转矩阵 ↔ 四元数[x, y, z, w] 格式
  • 旋转矩阵 ↔ 角轴:Rodrigues 公式
  • 外参类 ExtrinsicParam:欧拉/旋转矩阵/四元数/角轴多种初始化,齐次矩阵、点变换、复合与逆
  • 多格式输入解析:支持旋转矩阵+平移、四元数+平移、欧拉角+平移、4x4 齐次矩阵、JSON/proto/flex 四元数格式
  • 矩阵计算:支持统一格式输出、矩阵比较、A = C @ B / A = B @ D 求解

快速开始

from transform_base import (
    normalize_angle,
    standard_euler_to_rotation_matrix,
    rotation_matrix_to_standard_euler,
    ExtrinsicParam,
    parse_transform_input,
    transform_from_input,
    transform_to_all_formats,
    compare_transforms,
    solve_transform_equations,
)

# 欧拉角 -> 旋转矩阵 -> 欧拉角
euler = [10.0, 20.0, 30.0]  # roll, pitch, yaw (度)
R = standard_euler_to_rotation_matrix(*euler, order="ZYX")
euler_back = rotation_matrix_to_standard_euler(R, order="ZYX")

# 外参:欧拉角 + 平移
ext = ExtrinsicParam(euler=[0, 0, 90], translation=[1, 0, 0])
p_out = ext.transform_point([1, 0, 0])
ext_inv = ext.inverse()

# 多格式输入 -> 外参
raw = '''
"translation": {"x": 1, "y": 2, "z": 3},
"rotation": {"qx": 0.0, "qy": 0.0, "qz": 0.70710678, "qw": 0.70710678}
'''
parsed = parse_transform_input(raw, format_name="json_rotation_translation_qxyzw")
ext_from_input = transform_from_input(raw, format_name="json_rotation_translation_qxyzw")
all_formats = transform_to_all_formats(ext_from_input)

# 比较与方程求解
cmp_result = compare_transforms(ext, ext_inv.inverse())
solve_result = solve_transform_equations(ext, ext_from_input)

依赖

  • Python >= 3.10
  • numpy >= 1.20
  • PyYAML >= 6.0

支持的输入格式

  • rotation_matrix_translation
  • quaternion_translation
  • euler_degree_translation
  • homogeneous_matrix_4x4
  • json_rotation_translation
  • json_rotation_translation_qxyzw
  • translation_rotation_quaternion
  • rotation_translation_flex

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transform_base-0.0.3.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transform_base-0.0.3-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file transform_base-0.0.3.tar.gz.

File metadata

  • Download URL: transform_base-0.0.3.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for transform_base-0.0.3.tar.gz
Algorithm Hash digest
SHA256 6d5dd8001a36bb194fd8bfbf199a2c7ecb7c868fd6a8f84805385ceaea286803
MD5 878bae0fe763346332cddb0e2e80da8e
BLAKE2b-256 b49c276ee01b27821d30920236756827850a16b45a7810b6e098f5351b755e5a

See more details on using hashes here.

File details

Details for the file transform_base-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: transform_base-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for transform_base-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 506ef0641795801dc0cec455bd965d868dbbab2690f76a932915e58bf0f40032
MD5 8ca334c8c3fdc530d93bbe49f1dfef62
BLAKE2b-256 b190544ac336ab21ec977936f7d9dc70af0f3990a54adf12ac18ce0eccc4a182

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page