Re: [PATCH v7 5/6] iio: ABI: Add partial quaternion modifier
From: David Lechner
Date: Thu Mar 05 2026 - 09:55:12 EST
On 3/5/26 2:50 AM, Francesco Lavra wrote:
> On Wed, 2026-03-04 at 16:42 -0600, David Lechner wrote:
>> On 3/4/26 8:21 AM, Francesco Lavra wrote:
>>> On Wed, 2026-03-04 at 13:51 +0200, Andy Shevchenko wrote:
>>>> On Wed, Mar 04, 2026 at 09:07:05AM +0100, Francesco Lavra wrote:
>>>>> This modifier applies to the IIO_ROT channel type, and indicates a
>>>>> data
>>>>> representation that specifies the {x, y, z} components of the
>>>>> normalized
>>>>> quaternion vector.
>>>>
>>>> ...
>>>>
>>>>> +What: /sys/bus/iio/devices/iio:deviceX/in_rot_partial_qua
>>>>> tern
>>>>> ion_raw
>>>>
>>>>> + Raw value of {x, y, z} components of the quaternion
>>>>> vector. These
>>>>> + components represent the axis about which a
>>>>> rotation
>>>>> occurs, and are
>>>>> + subject to the following costraints:
>>>>> + - the quaternion vector is normalized, i.e. x^2 +
>>>>> y^2 +
>>>>> z^2 + w^2 = 1
>>>>> + - the rotation angle is within the [-180, 180]
>>>>> range,
>>>>> i.e. the w
>>>>> + component (which represents the amount of
>>>>> rotation)
>>>>> is non-negative
>>>>> + These constraints allow the w value to be
>>>>> calculated
>>>>> from the other
>>>>> + components: w = sqrt(1 - (x^2 + y^2 + z^2)).
>>>>
>>>> Just to double check if we really do not have a special mathematical
>>>> term
>>>> for
>>>> that already. If we do, I prefer to have that over odd "partial
>>>> quaternion".
>>>
>>> A quaternion is often represented as w + xi + yj + zk, i.e. it's
>>> composed
>>> of a real coefficient (w) and 3 imaginary coefficients (x, y, z). With
>>> this
>>> notation, the (x, y, z) components are referred to as the imaginary
>>> part of
>>> the quaternion.
>>> Alternatively, a quaternion is represented as the combination of a
>>> scalar
>>> value w and a 3D vector value (x, y, z). With this notation, the (x, y,
>>> z)
>>> components are referred to as the vector part of the quaternion; this
>>> can
>>> be confusing, since the quaternion as a whole is often considered as a
>>> 4D
>>> vector.
>>
>> I'm surprised there isn't a common name for this. When I went looking,
>> the
>> thing that came up most often is that Doom 3 used this in their MD5 file
>> format. So maybe IIO_MOD_DOOM3_QUATERNION? (joking)
>>
>> I do think we could come up with something better than "partial" though.
>>
>> My first thought is IIO_MOD_3D_QUATERNION since it is a 3-dimentional
>> number,
>> but I could see that being confusing to some since quaternions are
>> generally
>> used for rotations in 3-D space.
>>
>> Maybe something like IIO_MOD_3VALUE_QUATERNION or
>> IIO_MOD_COMPRESSED_QUATERNION
>> or just IIO_MOD_3QUATERNION?
>
> Or, since this represents the axis of rotation, perhaps something like
> IIO_MOD_QUATERNION_AXIS?
Sounds OK to me.