Skip to main content

A simple library for working with quaternions and vectors.

Project description

Introduction

Abstract

This library is primarily derived from the contributions of Geir Istad and has been released as a pip-installable package. The main objective of this library is to streamline operations involving vectors and quaternions, particularly in the context of working with Inertial Measurement Units (IMUs).

Library Structure and Functions

  • Quaternion:

    • get_product: Computes and returns the product of the current quaternion with another quaternion.

    • get_conjugate: Calculates and returns the conjugate of the quaternion.

    • get_magnitude: Determines and provides the magnitude of the quaternion.

    • normalize: Normalizes the quaternion to ensure unit length.

    • get_normalized: Retrieves the normalized form of the quaternion.

  • XYZVector:

    • get_magnitude: Computes and returns the magnitude of the vector.

    • normalize: Normalizes the vector to maintain unit length.

    • get_normalized: Retrieves the normalized version of the vector.

    • rotate: Rotates the vector based on a given quaternion.

    • get_rotated: Returns the vector after rotation, as per the specified quaternion.

About Rotation

In many scenarios, particularly in the context of Inertial Measurement Unit (IMU) applications, the rotation of a vector using a quaternion is a common requirement. For instance, the acceleration data acquired from an IMU is typically represented in a "body-frame," aligning with the IMU's axes.

However, in the realm of Inertial Navigation Systems (INS), having access to a world-frame acceleration vector is essential for accurate navigation. The illustration below illustrates the orientation of the world-frame and body-frame axes:

The rotation of a vector using a quaternion is achieved through the following formula:

$$A_p=q\times A\times q^*$$

where $q^*$ represents the conjugate of the quaternion q, and $A_p$ denotes the rotated original vector $A$.

Example

Let's consider the scenario where the accelerometer outputs $(0, g, 0)$, with $g$ representing the gravitational acceleration. Assuming the quaternion corresponding to this vector (obtained from the IMU) is $(0.7071, 0.7071, 0, 0)$.

Upon rotating the acceleration vector using the provided quaternion, the resulting vector would be $(0, 0, g)$, now aligned towards the Earth (assuming the z-axis points towards the Earth).

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

quat-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

quat-1.0.0-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file quat-1.0.0.tar.gz.

File metadata

  • Download URL: quat-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for quat-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7de1a9c25b40648b837ada6ba2efea67e031722971fe1e5266bc0716721c8abb
MD5 f647d00ac37f3daa88e28f66d7af460b
BLAKE2b-256 df3a1be655cf1961678f1b66f77cbd64a9d8263f343effc4d0aeed8fa95ddefa

See more details on using hashes here.

File details

Details for the file quat-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: quat-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for quat-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0c80943f89f2da22d1888cb732e9e7d6c19b1eeefdbeb6d26d1e2d51a63098c
MD5 d7ee25e2621fad3e4a2915b951a0f2d4
BLAKE2b-256 0aaa32d00b90603c2146a6385076e249320cddf3ca17a50773a72b5654f42600

See more details on using hashes here.

Supported by

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