Post · 1 min read· pp. 124–125
Quaternion.logarithm
Quaternion.logarithm
: Logarithm of Quaternion.
code
The logarithm of a **general quaternion**
q=(qwqv)
is obtained from:
logq=[log∥q∥uθ]
with:
uθ==∥qv∥qvarccos(∥q∥qw)
It is easy to see, that for a **pure quaternion**
q=(0qv), the
logarithm simplifies the computation through θ=arccos(0)=2π:
logq=[log∥q∥u2π]
Similarly, for **unitary quaternions** (∥q∥=1)
the logarithm is:
logq=[0uarccos(qw)]
which further reduces for **pure unitary quaternions** (qw=0 and ∥q∥=1)
to:
logq=[0u2π]
And for **real quaternions** (q=(qw000))
the logarithm is:
logq=[0000]
Returns:
: **log** – Logarithm of quaternion.
Return type:
: numpy.ndarray
Examples
```default
q = Quaternion([1.0, -2.0, 3.0, -4.0])
q.view()
Quaternion([ 0.18257419, -0.36514837, 0.54772256, -0.73029674])
q.logarithm
array([ 0. , -0.51519029, 0.77278544, -1.03038059])
q = Quaternion([0.0, 1.0, -2.0, 3.0])
q.view()
Quaternion([ 0. , 0.26726124, -0.53452248, 0.80178373])
q.logarithm
array([ 0. , 0.41981298, -0.83962595, 1.25943893])
```