pub struct Minkowski<const N: usize> {
pub coordinates: [f64; N],
}Expand description
A vector in N-dimensional Minkowski space.
Minkowski<N> implements (N-1,1)-dimensional Minkowski space with the
metric signature $(+ , \cdots , + , -)$. Minkowski supports
Vector operations such as vector addition and rescaling.
§Constructing Minkowski vectors
Similar to Cartesian, N-dimensional vectors can be
constructed using an array of (real-valued) coordinates. Three- and
four-dimensional vectors can also be constructed from tuples:
use hoomd_manifold::Minkowski;
fn from_array() -> Minkowski<5> {
Minkowski::from([1.0, 2.0, 3.0, 4.0, 5.0])
}
fn from_tuples() -> Minkowski<3> {
Minkowski::from((6.0, 7.0, 8.0))
}§Operating on Minkowski vectors
Minkowski implements everything from Vector, which includes vector
addition/subtraction and multiplication by a scalar.
use hoomd_manifold::Minkowski;
// Vector addition
let mut a = Minkowski::from([1.0, 1.0, 1.0, 1.0]);
let mut b = Minkowski::from([0.0, 0.0, 0.0, 2.0]);
a += b;
// Multiplication by a scalar
let mut c = a * 4.0;
// Division by a scalar
c /= 2.0;
assert_eq!(c, [2.0, 2.0, 2.0, 6.0].into());The distance metric on Minkowski space is given by the “spacetime interval”
d_M^2(\vec{u},\vec{v}) = (\vec{u}-\vec{v})^T \eta (\vec{u}-\vec{v})
= (u_1-v_1)^2 +\cdots + (u_{N-1}-v_{N-1})^2 - (u_N - v_N)^2Note that because this metric is not positive-definite, Minkowski this
“spacetime interval” is not a true inner-product, and therefore
Minkowski does not implement the methods of InnerProduct.
use hoomd_manifold::Minkowski;
use hoomd_vector::Metric;
let x = Minkowski::from([1.0, 0.0, 5.0]);
let y = Minkowski::from([0.0, 0.0, 3.0]);
assert_eq!(-3.0, x.distance_squared(&y));Fields§
§coordinates: [f64; N]The vector’s coordinates.
The final component is the one associated with a minus sign (-) in the metric.
Trait Implementations§
Source§impl<const N: usize> AbsDiffEq for Minkowski<N>
impl<const N: usize> AbsDiffEq for Minkowski<N>
Source§fn default_epsilon() -> Self::Epsilon
fn default_epsilon() -> Self::Epsilon
Source§fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool
§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
AbsDiffEq::abs_diff_eq].Source§impl<const N: usize> AddAssign for Minkowski<N>
impl<const N: usize> AddAssign for Minkowski<N>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<'de, const N: usize> Deserialize<'de> for Minkowski<N>
impl<'de, const N: usize> Deserialize<'de> for Minkowski<N>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<const N: usize> Distribution<Minkowski<N>> for StandardUniform
impl<const N: usize> Distribution<Minkowski<N>> for StandardUniform
Source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Minkowski<N>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Minkowski<N>
Sample a Minkowski vector from the uniform $[-1, 1]$ hypercube.
§Example
use hoomd_manifold::Minkowski;
use rand::{RngExt, SeedableRng, rngs::StdRng};
let mut rng = StdRng::seed_from_u64(1);
let v: Minkowski<3> = rng.random();§fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>where
R: Rng,
Self: Sized,
fn sample_iter<R>(self, rng: R) -> Iter<Self, R, T>where
R: Rng,
Self: Sized,
T, using rng as
the source of randomness. Read moreSource§impl<const N: usize> DivAssign<f64> for Minkowski<N>
impl<const N: usize> DivAssign<f64> for Minkowski<N>
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
/= operation. Read moreSource§impl HyperbolicRotate<Minkowski<4>> for UnitBiquaternion
impl HyperbolicRotate<Minkowski<4>> for UnitBiquaternion
Source§fn hyperbolic_rotate(&self, vector: &Minkowski<4>) -> Minkowski<4>
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 Matrix = HyperbolicRotationMatrix<4>
Source§impl<const N: usize> HyperbolicRotate<Minkowski<N>> for HyperbolicRotationMatrix<N>
impl<const N: usize> HyperbolicRotate<Minkowski<N>> for HyperbolicRotationMatrix<N>
Source§fn hyperbolic_rotate(&self, vector: &Minkowski<N>) -> Minkowski<N>
fn hyperbolic_rotate(&self, vector: &Minkowski<N>) -> Minkowski<N>
Rotate a Minkowski<N> by a HyperbolicRotationMatrix
§Examples
Rotate point in 2D hyperbolic space about z-axis:
use hoomd_manifold::{
HyperbolicAngle, HyperbolicRotate, HyperbolicRotationMatrix, Minkowski,
};
use std::f64::consts::PI;
let v = Minkowski::from([1.0, 0.0, 1.0]);
let spatial_rotation = HyperbolicAngle::from((PI / 2.0, 0.0_f64, 0.0_f64));
let matrix = HyperbolicRotationMatrix::from(spatial_rotation);
let rotated = matrix.hyperbolic_rotate(&v);
let c = Minkowski::from([(PI / 2.0).cos(), (PI / 2.0).sin(), 1.0]);
assert_eq!(c, rotated);Boost point in 2D hyperbolic space in x direction:
use hoomd_manifold::{
HyperbolicAngle, HyperbolicRotate, HyperbolicRotationMatrix, Minkowski,
};
use num::complex::Complex;
use std::f64::consts::PI;
let v = Minkowski::from([1.0, 0.0, 1.0]);
let small_boost = HyperbolicAngle::from((0.0_f64, 0.1_f64, 0.0_f64));
let matrix = HyperbolicRotationMatrix::from(small_boost);
let rotated = matrix.hyperbolic_rotate(&v);
let c = Minkowski::from([
(0.1_f64).sinh() + (0.1_f64).cosh(),
0.0,
(0.1_f64).sinh() + (0.1_f64).cosh(),
]);
assert_eq!(c, rotated);Zero angles and rapidities does nothing:
use hoomd_manifold::{
HyperbolicAngle, HyperbolicRotate, HyperbolicRotationMatrix, Minkowski,
};
use num::complex::Complex;
use std::f64::consts::PI;
let v = Minkowski::from([1.0, 2.0, 1.0]);
let identity = HyperbolicAngle::from((0.0_f64, 0.0_f64, 0.0_f64));
let matrix = HyperbolicRotationMatrix::from(identity);
let rotated = matrix.hyperbolic_rotate(&v);
let c = Minkowski::from([1.0, 2.0, 1.0]);
assert_eq!(c, rotated);Rotate point in 3D hyperbolic space about y axis using matrix representation:
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.0),
Complex::new((PI / 4.0).sin(), 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, 0.0, 0.0, 1.0]);
let rotation = HyperbolicRotationMatrix::from(v);
let rotated = rotation.hyperbolic_rotate(&x);
assert_relative_eq!(rotated, [0.0, 0.0, -1.0, 1.0].into(), epsilon = 1e-12);Boost point in 3D hyperbolic space in x direction using biquaternion algebra:
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, 0.25).sin(),
Complex::new(0.0, 0.0),
Complex::new(0.0, 0.0),
Complex::new(0.0, 0.25).cos(),
]);
let v = q.to_unit()?;
let boosted = v.hyperbolic_rotate(&x);
assert_relative_eq!(
boosted,
[(0.5_f64).sinh(), 0.0, 0.0, (0.5_f64).cosh()].into(),
epsilon = 1e-12
);Source§type Matrix = HyperbolicRotationMatrix<N>
type Matrix = HyperbolicRotationMatrix<N>
Source§impl<const N: usize> Metric for Minkowski<N>
impl<const N: usize> Metric for Minkowski<N>
Source§fn distance_squared(&self, other: &Self) -> f64
fn distance_squared(&self, other: &Self) -> f64
Computes the squared distance between two points in Minkowski space.
Employs the “mostly plusses” metric signature (+ … + -).
d^2_M(\vec{x},\vec{y}) = -(x_N-y_N)^2 + \sum_{i=1}^{N-1} (x_i - y_i)^2§Example
use hoomd_manifold::Minkowski;
use hoomd_vector::{Metric, Vector};
let x = Minkowski::from([0.0, 2.0, 3.0]);
let y = Minkowski::from([1.0, 0.0, 0.0]);
assert_eq!(-4.0, x.distance_squared(&y));Source§fn distance(&self, other: &Self) -> f64
fn distance(&self, other: &Self) -> f64
Source§fn n_dimensions(&self) -> usize
fn n_dimensions(&self) -> usize
Source§impl<const N: usize> MulAssign<f64> for Minkowski<N>
impl<const N: usize> MulAssign<f64> for Minkowski<N>
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
*= operation. Read moreSource§impl<const N: usize> RelativeEq for Minkowski<N>
impl<const N: usize> RelativeEq for Minkowski<N>
Source§fn default_max_relative() -> Self::Epsilon
fn default_max_relative() -> Self::Epsilon
Source§fn relative_eq(
&self,
other: &Self,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
RelativeEq::relative_eq].Source§impl<const N: usize> SubAssign for Minkowski<N>
impl<const N: usize> SubAssign for Minkowski<N>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more