UnitBiquaternion

Struct UnitBiquaternion 

Source
pub struct UnitBiquaternion(/* private fields */);
Expand description

Represent SO(3,1) with a normalized biquaternion.

Unit-norm Biquaternions furnish a representation of SO(3,1), analogous to quaternions and SO(3). If $\vec{x} = (x_1, x_2, x_3, x_4)$ is a vector in Minkowski space, then $\vec{x}$ can be mapped to a biquaternion

\vec{x} \mapsto X = [x_1, x_2, x_3,h x_4]

(where h is the imaginary number) whose squared norm is

|X|^2 = x_1^2 + x_2^2 + x_3^2 - x_4^2

It can be shown that, for a unit biquaternion $q$, the transformation

q^* X \overline{q} = X'

preserves the norm, i.e.,

|X|^2 = |X'|^2

We therefore have that this action by unit biquaternions produces a representation of SO(3,1). The biquaternion algebra can be used directly to transform Minkowski 4-vectors, or unit biquaternions can be represented as matrices using HyperbolicRotationMatrix<4>.

Like quaternions, the unit biquaternion

q = \cos(\theta/2) + \bf{i}\sin(\theta/2)

generates a rotation about the $\mathbf{i}$ axis by angle $\theta$:

use approxim::assert_relative_eq;
use hoomd_manifold::{
    Biquaternion, HyperbolicRotate, HyperbolicRotationMatrix, Minkowski,
    UnitBiquaternion,
};
use num::complex::Complex;
use std::f64::consts::PI;

let q = Biquaternion::from([
    Complex::new((PI / 4.0).sin(), 0.0),
    Complex::new(0.0, 0.0),
    Complex::new(0.0, 0.0),
    Complex::new((PI / 4.0).cos(), 0.0),
]);
let v = q.to_unit()?;
let x = Minkowski::from([1.0, 1.0, 1.0, 1.0]);
let rotation = HyperbolicRotationMatrix::from(v);
let rotated = rotation.hyperbolic_rotate(&x);
assert_relative_eq!(rotated, [1.0, -1.0, 1.0, 1.0].into(), epsilon = 1e-12);

However, biquaternions also generate boosts via

q = \cosh(v) + \mathbf{i}h\sinh(v)

which represents a boost of rapidity $v$ in the $\mathbf{i}$ direction:

use approxim::assert_relative_eq;
use hoomd_manifold::{
    Biquaternion, HyperbolicRotate, HyperbolicRotationMatrix, Minkowski,
    UnitBiquaternion,
};
use num::complex::Complex;
use std::f64::consts::PI;

let q = Biquaternion::from([
    Complex::new(0.0, (0.2_f64).sinh()),
    Complex::new(0.0, 0.0),
    Complex::new(0.0, 0.0),
    Complex::new((0.2_f64).cosh(), 0.0),
]);
let v = q.to_unit()?;
let x = Minkowski::from([0.0, 0.0, 0.0, 1.0]);
let boost = HyperbolicRotationMatrix::from(v);
let boosted = boost.hyperbolic_rotate(&x);
assert_relative_eq!(
    boosted,
    [(0.4_f64).sinh(), 0.0, 0.0, (0.4_f64).cosh()].into(),
    epsilon = 1e-12
);

Implementations§

Source§

impl UnitBiquaternion

Source

pub fn normalized(self) -> Self

Normalize a biquaternion.

Source

pub fn norm_squared(self) -> Complex<f64>

Compute the square of the norm of a biquaternion.

Trait Implementations§

Source§

impl Clone for UnitBiquaternion

Source§

fn clone(&self) -> UnitBiquaternion

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnitBiquaternion

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Distribution<UnitBiquaternion> for StandardUniform

Source§

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitBiquaternion

Sample a random UnitBiquaternion

§Example
use approxim::assert_relative_eq;
use hoomd_manifold::{Biquaternion, UnitBiquaternion};
use num::complex::Complex;
use rand::{RngExt, SeedableRng, rngs::StdRng};

let mut rng = StdRng::seed_from_u64(1);
let v: UnitBiquaternion = rng.random();
assert_relative_eq!(v.norm_squared().re, 1.0, epsilon = 1e-12);
§

fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
§

fn map<F, S>(self, func: F) -> Map<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Map sampled values to type S Read more
Source§

impl From<UnitBiquaternion> for HyperbolicRotationMatrix<4>

Source§

fn from(q: UnitBiquaternion) -> HyperbolicRotationMatrix<4>

Converts to this type from the input type.
Source§

impl HyperbolicRotate<Minkowski<4>> for UnitBiquaternion

Source§

fn hyperbolic_rotate(&self, vector: &Minkowski<4>) -> Minkowski<4>

Transform a Minkowski<4> by a UnitBiquaternion.

\overline{\mathbf{q}} \vec{a} \mathbf{q}^*
§Examples

Rotation about z axis:

use approxim::assert_relative_eq;
use hoomd_manifold::{
    Biquaternion, HyperbolicRotate, Minkowski, UnitBiquaternion,
};
use num::complex::Complex;
use std::f64::consts::PI;

let x = Minkowski::from([1.0, 0.0, 0.0, 1.0]);
let q = Biquaternion::from([
    Complex::new(0.0, 0.0),
    Complex::new(0.0, 0.0),
    Complex::new((PI / 4.0).sin(), 0.0),
    Complex::new((PI / 4.0).cos(), 0.0),
]);
let v = q.to_unit_unchecked();
let rotated = v.hyperbolic_rotate(&x);
assert_relative_eq!(rotated, [0.0, 1.0, 0.0, 1.0].into(), epsilon = 1e-12);

Boost in x direction:

use approxim::assert_relative_eq;
use hoomd_manifold::{
    Biquaternion, HyperbolicRotate, Minkowski, UnitBiquaternion,
};
use num::complex::Complex;
use std::f64::consts::PI;

let x = Minkowski::from([0.0, 0.0, 0.0, 1.0]);
let q = Biquaternion::from([
    Complex::new(0.0, PI / 4.0).sin(),
    Complex::new(0.0, 0.0),
    Complex::new(0.0, 0.0),
    Complex::new(0.0, PI / 4.0).cos(),
]);
let v = q.to_unit_unchecked();
let boosted = v.hyperbolic_rotate(&x);
assert_relative_eq!(
    boosted,
    [(PI / 2.0).sinh(), 0.0, 0.0, (PI / 2.0).cosh()].into(),
    epsilon = 1e-12
);
Source§

type Matrix = HyperbolicRotationMatrix<4>

Type of the related rotation matrix
Source§

impl PartialEq for UnitBiquaternion

Source§

fn eq(&self, other: &UnitBiquaternion) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for UnitBiquaternion

Source§

impl StructuralPartialEq for UnitBiquaternion

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.